note 74142 added to function.is-numeric

From: Date: Tue, 27 Mar 2007 12:05:37 +0000
Subject: note 74142 added to function.is-numeric
Groups: php.notes 
Request: Send a blank email to php-notes+get-124839@lists.php.net to get a copy of this message
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 ---- Server IP: 194.109.193.76 Probable Submitter: 82.92.27.234 ---- Manual Page -- http://www.php.net/manual/en/function.is-numeric.php Edit -- https://master.php.net/note/edit/74142 Del: integrated -- https://master.php.net/note/delete/74142/integrated Del: useless -- https://master.php.net/note/delete/74142/useless Del: bad code -- https://master.php.net/note/delete/74142/bad+code Del: spam -- https://master.php.net/note/delete/74142/spam Del: non-english -- https://master.php.net/note/delete/74142/non-english Del: in docs -- https://master.php.net/note/delete/74142/in+docs Del: other reasons-- https://master.php.net/note/delete/74142 Reject -- https://master.php.net/note/reject/74142 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124839) next »