note 74013 added to function.is-numeric
| From: | (at) | Date: | Tue, 20 Mar 2007 22:07:23 +0000 |
| Subject: | note 74013 added to function.is-numeric | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124646@lists.php.net to get a copy of this message | ||
In reply to www.kigoobe.com, a more strict expression is
<?php
function my_is_numeric($value)
{
return (preg_match ("/^(-){0,1}([0-9]+)(,[0-9][0-9][0-9])*([.][0-9]){0,1}([0-9]*)$/",
$value) == 1);
}
?>
This will not match strings like -6,77.8,8 which are matched by the below expression, and instead
requires a single decimal point, with at least one character following, and only permits
comma-separation when the right hand side is a triplet.
----
Server IP: 194.145.210.3
Probable Submitter: 86.129.76.181
----
Manual Page -- http://www.php.net/manual/en/function.is-numeric.php
Edit -- https://master.php.net/note/edit/74013
Del: integrated -- https://master.php.net/note/delete/74013/integrated
Del: useless -- https://master.php.net/note/delete/74013/useless
Del: bad code -- https://master.php.net/note/delete/74013/bad+code
Del: spam -- https://master.php.net/note/delete/74013/spam
Del: non-english -- https://master.php.net/note/delete/74013/non-english
Del: in docs -- https://master.php.net/note/delete/74013/in+docs
Del: other reasons-- https://master.php.net/note/delete/74013
Reject -- https://master.php.net/note/reject/74013
Search -- https://master.php.net/manage/user-notes.php