note 51361 rejected from function.strlen by nlopess
| From: | nlopess@php.net | Date: | Wed, 30 Mar 2005 18:58:29 +0000 |
| Subject: | note 51361 rejected from function.strlen by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-87194@lists.php.net to get a copy of this message | ||
Note Submitter: snake at crystalminds dot net
----
We had the same problem you guys have, but we fixed the problem the following way.
function Price ($Something)
{
$Temp = (int)($Something * 100);
$Temp = (string)$Temp ;
$Temp = substr($Temp ,0,strlen($Temp ) - 2) . "." . substr($Temp ,strlen($Temp )-2,2);
return $Temp;
}
print Price(2.5345667);
I hope we helped some people sharing this code. I don't really know if there is an easier way,
if so could someone share that code or function with us?