note 69366 deleted from function.is-numeric by cmb

From: Date: Sun, 23 Jun 2019 10:35:42 +0000
Subject: note 69366 deleted from function.is-numeric by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211351@lists.php.net to get a copy of this message
Note Submitter: ja at krystof dot org ---- 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; } ?>

« previous php.notes (#211351) next »