note 74142 deleted from function.is-numeric by crell

From: Date: Mon, 18 Apr 2022 14:57:52 +0000
Subject: note 74142 deleted from function.is-numeric by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218284@lists.php.net to get a copy of this message
Note Submitter: Elwin van Huissteden ---- To James holwell: Maybe your function was more strickt, but profides FALSE to any numeric string that wasnt written in the English/American notition. To enable a person to use the both the English/American and the rest of the world's way: <?php function my_is_numeric($value) { return (preg_match ("/\A(-){0, 1}([0-9]+)((,|.)[0-9]{3, 3})*((,|.)[0-9]){0, 1}([0-9]*)\z/" ,$value) == 1); } ?> Other than that, i'd recommend using yours, if it works (i havent tested either yours or mine) By using mine, there might be a slight chance to not being able to do calculations with the numeric string if it's not the English/American way. (*Note: -the E/A way of writing 1 million (with decimal for 1/50): 1,000,000.02 -the global way of writing 1 million (with decimal for 1/50): 1.000.000,02

« previous php.notes (#218284) next »