php/regex quiz

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
Locked
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

php/regex quiz

Post by Red Squirrel »

took me nearly half an hour to debug a problem with the forum id "10" being validated as not being a valid number, turned out it was VERY simple to fix, so thought I'd post it to see if anyone can see what's wrong with that function. Tip: you only need to add, remove, or replace 1 single char. :lol:

Code: Select all

//returns 0 if it is not a number
function SBNumOnly($text)
{
if(!preg_match("#^([1-9]*)$#",$text))return 0;
else return $text;
}
[code]

 

[color=#888888][size=85]Archived topic from Iceteks,  old topic ID:3746, old post ID:30475[/size][/color]
Honk if you love Jesus, text if you want to meet Him!
Locked