note 87658 deleted from function.floatval by danbrown

From: Date: Mon, 15 Dec 2008 16:36:15 +0000
Subject: note 87658 deleted from function.floatval by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148179@lists.php.net to get a copy of this message
Note Submitter: info at marc-gutt dot de Reason: integrated ---- My last function results were buggy if you float: 2,5 It resulted: 2.05 Use this one instead: <?php function floatvalue($value) { return floatval(preg_replace('#^([-]*[0-9\.,\' ]+?)((\.|,){1}([0-9-]{1,2}))*$#e', "str_replace(array('.', ',', \"'\", ' '), '', '\\1') . '.\\4'", $value)); } ?> Now it has to be free of bugs. Updates & Support: http://www.programmierer-forum.de/floatvalue-t82298.htm regards

« previous php.notes (#148179) next »