note 74013 deleted from function.is-numeric by crell
| From: | crell@php.net | Date: | Mon, 18 Apr 2022 14:51:20 +0000 |
| Subject: | note 74013 deleted from function.is-numeric by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218262@lists.php.net to get a copy of this message | ||
Note Submitter: james.holwell( at )exeter.ox.ac.uk
----
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.