note 87658 added to function.floatval

From: Date: Mon, 15 Dec 2008 16:31:49 +0000
Subject: note 87658 added to function.floatval
Groups: php.notes 
Request: Send a blank email to php-notes+get-148178@lists.php.net to get a copy of this message
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 ---- Server IP: 217.160.72.57 Probable Submitter: 80.136.82.67 ---- Manual Page -- http://www.php.net/manual/en/function.floatval.php Edit -- https://master.php.net/note/edit/87658 Del: integrated -- https://master.php.net/note/delete/87658/integrated Del: useless -- https://master.php.net/note/delete/87658/useless Del: bad code -- https://master.php.net/note/delete/87658/bad+code Del: spam -- https://master.php.net/note/delete/87658/spam Del: non-english -- https://master.php.net/note/delete/87658/non-english Del: in docs -- https://master.php.net/note/delete/87658/in+docs Del: other reasons-- https://master.php.net/note/delete/87658 Reject -- https://master.php.net/note/reject/87658 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148178) next »