note 80326 deleted from function.is-float by nikic

From: Date: Thu, 23 Aug 2012 12:06:56 +0000
Subject: note 80326 deleted from function.is-float by nikic
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190189@lists.php.net to get a copy of this message
Note Submitter: WHITE new media architects - Jeroen ---- The above printed "is_true_float" function is not correct. It gives wrong answers on the following tests: is_true_float("-4,123"); # returns false is_true_float("0,123"); # returns false So I changed the function to correctly handle qouted negative floats and quoted floats near zero: <?php function is_true_float($mVal) { return ( is_float($mVal) || ( (float) $mVal != round($mVal) || strlen($mVal) != strlen( (int) $mVal) ) && $mVal != 0 ); } ?>

« previous php.notes (#190189) next »