note 44038 added to function.floatval
| From: | edu_chaos at hotmail dot com | Date: | Tue, 13 Jul 2004 12:16:22 +0000 |
| Subject: | note 44038 added to function.floatval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73146@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.floatval.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44038
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44038&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44038&report=yes
Search -- http://master.php.net/manage/user-notes.php