I am using the money_format() function in PHP, which gives the following error:
Fatal error: Call to undefined function money_format()
>
@Ajeet toMoney function looks good, but it is not working for the '0899'
Change length Into strlen()
$j = (($j = $i.length) > 3) ? $j % 3 : 0;
so change into below like
$j = (($j = strlen($i)) > 3) ? $j % 3 : 0;
Now this will work for any data.
3) ? $j % 3 : 0;
return $symbol.$sign .($j ? substr($i,0, $j) + $t : '').preg_replace('/(\d{3})(?=\d)/',"$1" + $t,substr($i,$j)) ;
}
echo toMoney('0899'/100); //Note: single quotes mandatory
?>