note 100405 added to function.number-format

From: Date: Wed, 13 Oct 2010 21:52:40 +0000
Subject: note 100405 added to function.number-format
Groups: php.notes 
Request: Send a blank email to php-notes+get-173196@lists.php.net to get a copy of this message
Caution should be taken with large "string" values. This is due to the precision issues with converting a string to a float. For example: $org_num = "255173029255255255"; echo "<br>org: ".$org_num; echo "<br>".number_format($org_num); returns: org: 255173029255255255 255,173,029,255,255,264 Here is the function that can be used instead function numberFormat($num) { return preg_replace("/(?<=\d)(?=(\d{3})+(?!\d))/",",",$num); } ---- Server IP: 69.147.83.197 Probable Submitter: 166.70.22.187 ---- Manual Page -- http://www.php.net/manual/en/function.number-format.php Edit -- https://master.php.net/note/edit/100405 Del: integrated -- https://master.php.net/note/delete/100405/integrated Del: useless -- https://master.php.net/note/delete/100405/useless Del: bad code -- https://master.php.net/note/delete/100405/bad+code Del: spam -- https://master.php.net/note/delete/100405/spam Del: non-english -- https://master.php.net/note/delete/100405/non-english Del: in docs -- https://master.php.net/note/delete/100405/in+docs Del: other reasons-- https://master.php.net/note/delete/100405 Reject -- https://master.php.net/note/reject/100405 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173196) next »