note 44038 deleted from function.floatval by tomsommer
| From: | tomsommer@php.net | Date: | Tue, 13 Jul 2004 18:17:36 +0000 |
| Subject: | note 44038 deleted from function.floatval by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73175@lists.php.net to get a copy of this message | ||
Note Submitter: edu_chaos@hotmail.com
----
Hi there.
A small func that returns the floatval in a string...
<?php
/**
* float2string
* @param string $in
*/
function float2string( $in = "" )
{
if( eregi("([0-9]*)([\.,])([0-9]*)",$in,$temp) )
{
if( strlen($temp[3]) == 1 )
$dec = ",". $temp[3][0] . "0";
else
$dec = ",". substr($temp[3],0,2);
$in = $temp[1];
} else {
$dec = ",00";
}
return( $in.$dec );
}
?>
I haven´t made many tests, but I guess it works !
[]s