php/regex quiz
Posted: Sun Sep 25, 2005 3:03 pm
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.
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]