note 26509 added to function.is-int
| From: | criess at rack1 dot php dot net | Date: | Fri, 01 Nov 2002 22:53:30 +0000 |
| Subject: | note 26509 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38892@lists.php.net to get a copy of this message | ||
The above examples fail when $str = "3.0" because PHP's equality operator evaluates
it in a numeric context.
How about this function:
function str_is_int($str) {
return strcmp($str , (int)$str);
}
Of course the above fails for $str = "+5" or $str = "-0" but oh well.
--
http://www.php.net/manual/en/function.is-int.php
http://master.php.net/manage/user-notes.php?action=edit+26509
http://master.php.net/manage/user-notes.php?action=delete+26509
http://master.php.net/manage/user-notes.php?action=reject+26509