I am using the money_format() function in PHP, which gives the following error:
Fatal error: Call to undefined function money_format()
>
I don't understand why @Ajeet is making it so complicated why not do like this, It also now works for 4 digit numbers to answer @bharanikumar "but it is not working for the '0899'"
function toMoney($val,$symbol='$',$r=2)
{
$n = $val;
$sign = ($n < 0) ? '-' : '';
$i = number_format(abs($n),$r);
return $symbol.$sign.$i;
}