Tag:strlen string php turn function -- Chinese ring remove
function Floatohz ($value) {
$result = ";
$v _a=array (' min ', ' Corner ', ' 0 ', ' block ', ' ten ', ', ' hundred ', ' thousand ', ' million ', ' ten ', ' hundred ', ' thousand ', ' billion ');
$v _b=array (' 0 ', ' one ', ' two ', ' three ', ' four ', ' five ', ' VI ', ' VII ', ' VIII ', ' IX ', ' ten ');
$v _c=array ();
$value = (string) $value;
Keep two digits after the decimal point
$value =sprintf ("%0.2f", $value);
Get string length
$len =strlen ($value);
Remove string from back to front
for ($i = $len; $i >=0; $i--) {
$val = $value [$i];
if ($val! = '. ') {
When encountered is 0 o'clock without units
if ($val = = ' 0 ') {
$v _c[]= $v _b[$val];
} else{
e.g. Four points
$v _c[]= $v _b[$val]. $v _a[$len-$i-1];
}
}
}
Array inversion
$v _c=array_reverse ($v _c);
Output from the past
foreach ($v _c as $val) {
$result. = $val;
}
unset ($v _a); unset ($v _b); unset ($v _c);
return $result;
}
$value = ' 45123056.78 ';
$value = ' 23058.04 ';
Print floatohz ($value);
Exit
(EXT) PHP Digital amount to Chinese capital amount