note 38225 added to function.preg-replace

From: Date: Fri, 12 Dec 2003 21:37:23 +0000
Subject: note 38225 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-61874@lists.php.net to get a copy of this message
Comma Punctuation in Numbers Here's an easy way to add commas in the right places when formatting a number (for the US at least :-) $val = 12345678; $valWithCommas = $val; while (preg_match("/\d\d\d\d/", $valWithCommas)) { $valWithCommas = preg_replace("/(\d+)(\d\d\d)/", "$1,$2", $valWithCommas); } print $valWithCommas; Output is 12,345,678 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38225 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38225&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38225&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61874) next »