Money Format In PHP

function my_money_format($num){
        $thousand=substr($taka, -3);
                $pp[$i]=substr($taka, -2);
                $pp[$i]=substr($taka, -1);
            $taka_add .=$pp[$j].',';
        return $taka_add.$thousand.".".$money[1];
        return $money[0].".".$money[1];    
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<form name="form1" id="form1" action="index.php" method="post">
<input name="f" id="f" type="text" value="<?php echo $_POST['f'];?>" />
  <input type="submit"  name="Submit" value="Format" class="button" />
  <input name="access" type="hidden" id="access" value="1" ></div>
echo  my_money_format($num);


Okay, so what’s wrong with PHP’s [fphp]money_format[/fphp] function?

Or even better intl’s NumberFormatter

Off Topic:

Ren nice to hear from you! Steve

If you use my script then you got output like that

Input = 152469854
Output= 15,24,69,854

Input= 12541362547589

My script is simple and easy.

Except, the money_format function can do that–and correctly (unlike your output example where you grouped numbers by twos instead of threes). It’s rare that rewriting a built-in function is necessary. Although it might be a good exercise on occasion, the built-in functions are typically more efficient. They are there so you don’t have to waste time building them and can get to building your site/app more quickly.