title: PHP | Custom Indian Money format function doesn't consider decimals
body: <p>I have this function which converts a number to Indian money format.</p>
  
  <pre><code>function IND_money_format($money)
  {
  $len = strlen($money);
  $m = '';
  $money = strrev($money);
  for($i=0;$i&lt;$len;$i++){
      if(( $i==3 || ($i&gt;3 &amp;&amp; ($i-1)%2==0) )&amp;&amp; $i!=$len){
          $m .=',';
      }
      $m .=$money[$i];
  }
  return strrev($m);
  }
  </code></pre>
  
  <p>Output is fine if I give whole numbers as input and not decimals.
  ex:</p>
  
  <pre><code>3 =&gt; 3
  30 =&gt; 30
  300 =&gt; 300
  3000  =&gt; 3,000
  459600 =&gt;  4,59,600
  </code></pre>
  
  <p>But if I give a decimal number the output gets corrupt
  ex:</p>
  
  <pre><code>379.50 =&gt; 37,9.5 
  </code></pre>
  
  <p><em>How can I fix this?</em></p>