note 92247 added to function.is-numeric

From: Date: Wed, 15 Jul 2009 20:34:20 +0000
Subject: note 92247 added to function.is-numeric
Groups: php.notes 
Request: Send a blank email to php-notes+get-158350@lists.php.net to get a copy of this message
if speed is important, the liberal use of regex should be avoided, especially complex ones like those here. For most purposes, this will be sufficient and has the advantages of both speed and clarity. $BoolResult = empty(trim($Test, '+-.,0123456789')); If the $Test contains any character that is not a valid part of a number the remaining string will not be empty. if you want to be more restrictive of the '+-' then you can use a separate trim for that and nest it. Keep in mind that some notations pt the sign to the right of the number instead of to the left. Depending upon your specific application you can also choose to ignore spaces and allow for 'e' notation. I also use this approach when testing for other character sets such as Hex. ---- Server IP: 64.71.164.2 Probable Submitter: 65.101.132.229 ---- Manual Page -- http://www.php.net/manual/en/function.is-numeric.php Edit -- https://master.php.net/note/edit/92247 Del: integrated -- https://master.php.net/note/delete/92247/integrated Del: useless -- https://master.php.net/note/delete/92247/useless Del: bad code -- https://master.php.net/note/delete/92247/bad+code Del: spam -- https://master.php.net/note/delete/92247/spam Del: non-english -- https://master.php.net/note/delete/92247/non-english Del: in docs -- https://master.php.net/note/delete/92247/in+docs Del: other reasons-- https://master.php.net/note/delete/92247 Reject -- https://master.php.net/note/reject/92247 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158350) next »