note 69366 added to function.is-numeric

From: Date: Sat, 02 Sep 2006 13:10:48 +0000
Subject: note 69366 added to function.is-numeric
Groups: php.notes 
Request: Send a blank email to php-notes+get-116627@lists.php.net to get a copy of this message
Here is a simple function to recognize whether the value is a natural number: (Zero is often exclude from the natural numbers, that's why there's the second parameter.) <?php function is_natural($val, $acceptzero = false) { $return = ((string)$val === (string)(int)$val); if ($acceptzero) $base = 0; else $base = 1; if ($return && intval($val) < $base) $return = false; return $return; } ?> ---- Server IP: 212.24.129.110 Probable Submitter: 212.80.90.18 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.is-numeric.php Edit -- https://master.php.net/note/edit/69366 Del: integrated -- https://master.php.net/note/delete/69366/integrated Del: useless -- https://master.php.net/note/delete/69366/useless Del: bad code -- https://master.php.net/note/delete/69366/bad+code Del: spam -- https://master.php.net/note/delete/69366/spam Del: non-english -- https://master.php.net/note/delete/69366/non-english Del: in docs -- https://master.php.net/note/delete/69366/in+docs Del: other reasons-- https://master.php.net/note/delete/69366 Reject -- https://master.php.net/note/reject/69366 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116627) next »