note 71022 added to function.is-int
| From: | mikko at sorl dot net | Date: | Wed, 08 Nov 2006 18:19:22 +0000 |
| Subject: | note 71022 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119519@lists.php.net to get a copy of this message | ||
I created and used this function:
<?php
function is_natural($x) {
return (string)$x === (string)(int)abs($x);
}
?>
It returns TRUE if the argument is a natural number (including 0) even if the argument is a string
such as "666".
----
Server IP: 193.27.201.10 (proxied: 193.27.201.10 1.0 www1.shellkonto.se:3128 (squid/2.5.STABLE4))
Probable Submitter: 213.114.99.43
----
Manual Page -- http://www.php.net/manual/en/function.is-int.php
Edit -- https://master.php.net/note/edit/71022
Del: integrated -- https://master.php.net/note/delete/71022/integrated
Del: useless -- https://master.php.net/note/delete/71022/useless
Del: bad code -- https://master.php.net/note/delete/71022/bad+code
Del: spam -- https://master.php.net/note/delete/71022/spam
Del: non-english -- https://master.php.net/note/delete/71022/non-english
Del: in docs -- https://master.php.net/note/delete/71022/in+docs
Del: other reasons-- https://master.php.net/note/delete/71022
Reject -- https://master.php.net/note/reject/71022
Search -- https://master.php.net/manage/user-notes.php