note 11924 modified in function.substr-replace by felipe
| From: | felipe@php.net | Date: | Tue, 22 Jul 2008 19:00:22 +0000 |
| Subject: | note 11924 modified in function.substr-replace by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142539@lists.php.net to get a copy of this message | ||
[Editor's note: for a much simpler solution, use number_format()]
I had a situation in which I needed to add a comma to the third position of a number(the price of
something).
<?php
$price = "12000";
$price = substr_replace ($price, ',', -3, 0)";
?>
the result would be 12,000
the -3 counts from right to left. a regular 3 would count from left to right
I hope this helps...
--was--
[Editor's note: for a much simpler solution, use number_format()]
I had a situation in which I needed to add a comma to the third position of a number(the price of
something).
<p>
$price = "12000";<br>
$price = substr_replace ($price, ',', -3, 0)";<br>
the result would be 12,000<p>
the -3 counts from right to left. a regular 3 would count from left to right
I hope this helps...
http://php.net/manual/en/function.substr-replace.php