title: php abbreviating numbers with K/M
body: <p>The function below finds the number, rounds it off and puts a K or M on the end of it </p>
  
  <p>IE: 25000 becomes 25K</p>
  
  <pre><code>function abbr_no($number) {
   $number  = preg_replace('/[^0-9]/', '', $number);
   $numbers = array('', 'K', 'M');
  if ($number == 0) { 
   return('n/a'); 
   } else {
   return (round($number/pow(10000, ($i = floor(log($number, 10000)))), 0) . $numbers[$i]);
   }
  }
  </code></pre>
  
  <p>and so it basically does what I want, but as is for a number like <em>389345</em> it rounds it off and spits out <em>39K</em> (as it should) however I would like the result to be <em>398K</em> (3 digit number)</p>
  
  <p>Now in the last return line:</p>
  
  <pre><code>0) . $numbers[$i]);
  </code></pre>
  
  <p>if I change the 0 to a 1 the result becomes <em>39.8K</em> but again I don't want the decimal point so I am currently stuck and have hit a brickwall</p>
  
  <p>As always all help is appreciated and thank you in advance.</p>