note 85346 added to function.floatval

From: Date: Tue, 26 Aug 2008 22:55:57 +0000
Subject: note 85346 added to function.floatval
Groups: php.notes 
Request: Send a blank email to php-notes+get-143850@lists.php.net to get a copy of this message
Instead of Michiels function try this one: <?php function floatvalue($value) { $value = preg_replace('#^([-]*[0-9\.,\' ]+?)((\.|,){1}([0-9-]{1,2}))*$#e', "str_replace(array('.', ',', \"'\", ' '), '', '\\1') . '.' . sprintf('%02d','\\4')", $value); return floatval($value); } ?> It is much shorter and able to handle those one, too: xx,- xx,-- xx'xxx,xx After using floatvalue() you can go forward with number_format() as usual. ---- Server IP: 217.160.72.57 Probable Submitter: 80.136.99.68 ---- Manual Page -- http://www.php.net/manual/en/function.floatval.php Edit -- https://master.php.net/note/edit/85346 Del: integrated -- https://master.php.net/note/delete/85346/integrated Del: useless -- https://master.php.net/note/delete/85346/useless Del: bad code -- https://master.php.net/note/delete/85346/bad+code Del: spam -- https://master.php.net/note/delete/85346/spam Del: non-english -- https://master.php.net/note/delete/85346/non-english Del: in docs -- https://master.php.net/note/delete/85346/in+docs Del: other reasons-- https://master.php.net/note/delete/85346 Reject -- https://master.php.net/note/reject/85346 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143850) next »