NogDog wrote:Ahh, I see. I was thinking of "positive integer" as "non-negative integer".
Your regex should work fine. It might be interesting to test whether your preg_match() exectues faster/slower than something like:
if(ctype_digit($num) && $num) {
Thanks for the piece of advice.
It works quite well
function isNumeric($num){
return (ctype_digit($num) && !empty($num));
}
var_dump(isNumeric('5'));//true
var_dump(isNumeric(''));//false
var_dump(isNumeric('0'));//false
var_dump(isNumeric('01'));//true ;(
var_dump(isNumeric('0001'));//true ;( ;( ;(
Because I must use the method to check
a GET value I must take into account which
way is faster/slower.
Bye.