note 86796 added to function.is-numeric
| From: | (nadim@alienworkers.com) | Date: | Tue, 04 Nov 2008 09:53:38 +0000 |
| Subject: | note 86796 added to function.is-numeric | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146109@lists.php.net to get a copy of this message | ||
Using SpT_King James example, i've re-wrote to cater for digits starting with '+',
commas ',' or period '.'
function is_numeric_regex($str)
{
$str = "{$str}";
if (in_array($str[0], array('-', '+'))) $str = "{$str[0]}0" .
substr($str, 1);
else $str = "0{$str}";
$eng = preg_match ("/^[+,-]{0,1}([0-9]+)(,[0-9][0-9][0-9])*([.][0-9]){0,1}([0-9]*)$/"
, $str) == 1;
$world = preg_match
("/^[+,-]{0,1}([0-9]+)(.[0-9][0-9][0-9])*([,][0-9]){0,1}([0-9]*)$/" , $str) == 1;
return ($eng or $world);
}
----
Server IP: 69.147.83.197
Probable Submitter: 196.27.71.225
----
Manual Page -- http://www.php.net/manual/en/function.is-numeric.php
Edit -- https://master.php.net/note/edit/86796
Del: integrated -- https://master.php.net/note/delete/86796/integrated
Del: useless -- https://master.php.net/note/delete/86796/useless
Del: bad code -- https://master.php.net/note/delete/86796/bad+code
Del: spam -- https://master.php.net/note/delete/86796/spam
Del: non-english -- https://master.php.net/note/delete/86796/non-english
Del: in docs -- https://master.php.net/note/delete/86796/in+docs
Del: other reasons-- https://master.php.net/note/delete/86796
Reject -- https://master.php.net/note/reject/86796
Search -- https://master.php.net/manage/user-notes.php