note 79634 deleted from function.is-float by felipe

From: Date: Sun, 16 Dec 2007 01:16:54 +0000
Subject: note 79634 deleted from function.is-float by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133611@lists.php.net to get a copy of this message
Note Submitter: nicholas at blasgen dot com Reason: 1 ---- Your function thinks my address is a floating point number. So it's not perfect. Really what I want is a function that allows ctype_digit() to fail once, but only once, when it hits a period. function better_float_check($float) { $periods=0; $split = split('', $float); foreach ($split as $s) { if (!ctype_digit($s)) { if ($s!='.') return false; else $periods++; } } if ($periods==1) return true; // all digits and only 1 decimal else return false; // more than one decimal }

« previous php.notes (#133611) next »