note 15968 added to function.is-numeric
| From: | tvali at email dot ee | Date: | Wed, 10 Oct 2001 16:53:04 +0000 |
| Subject: | note 15968 added to function.is-numeric | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18789@lists.php.net to get a copy of this message | ||
I changed function sent by
"ealma@hotmail.com 18-May-2001 12:02"
a little bit (it should be faster now).
Here is some code that will detect large values for numeric and for PHP3.
function is_num($s) {
for ($i=0; $i<strlen($s); $i++) {
if (($s[$i]<'0') or ($s[$i]>'9')) {return false;}
}
return true;
}
You can also check only the first char in string
(($s[0])<'9')and($s[0]>'0')), since php converts string to numeric only
from beginning to the last digit.
--
http://www.php.net/manual/en/function.is-numeric.php
http://master.php.net/manage/user-notes.php?action=edit+15968
http://master.php.net/manage/user-notes.php?action=delete+15968
http://master.php.net/manage/user-notes.php?action=reject+15968