title: Converting number to indian money format
body: <p>I am trying to convert number to indian money format LIke</p>
  
  <pre><code>100000 = 1,00,000
  </code></pre>
  
  <p>I have use </p>
  
  <pre><code>$explrestunits = "" ;
          if(strlen($num)&gt;3){
              $lastthree = substr($num, strlen($num)-3, strlen($num));
              $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits
              $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
              $expunit = str_split($restunits, 2);
              for($i=0; $i&lt;sizeof($expunit); $i++){
                  // creates each of the 2's group and adds a comma to the end
                  if($i==0)
                  {
                      $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer
                  }else{
                      $explrestunits .= $expunit[$i].",";
                  }
              }
              $thecash = $explrestunits.$lastthree;
          } else {
              $thecash = $num;
          }
          return $thecash; // writes the final format where $currency is the currency symbol.
  </code></pre>
  
  <p>But when i Use Minus sign <code>(-)</code> with <code>10000</code> (Five Digit Number) It returns Output <code>0,10,000</code> </p>
  
  <p>It should be <code>-10,000</code>
  Have you any idea..</p>