title: Break down number into thousands,hundreds,etc
body: <p>I'm currently putting together a cheque printing solution for my company. When printing the cheque you need to print the number of millions,hundred thousands,ten thousands,thousands, hundreds,tens and units (pounds/dollars/euros etc ) from the amount being paid.</p>
  
  <p>In the case of 111232.23 the following is correctly output from the code I have written below. I cant help feeling that there is a more efficient or reliable method of doing this? Does anyone know of a library/class math technique that does this?</p>
  
  <pre><code>float(111232.23)
  Array
  (
      [100000] =&gt; 1
      [10000] =&gt; 1
      [1000] =&gt; 1
      [100] =&gt; 2
      [10] =&gt; 3
      [1] =&gt; 2
  )
  
  &lt;?php
  
  $amounts = array(111232.23,4334.25,123.24,3.99);
  
  function cheque_format($amount)
  {
      var_dump($amount);
      #no need for millions
      $levels = array(100000,10000,1000,100,10,1);
      do{
          $current_level = current($levels);
          $modulo = $amount % $current_level;
          $results[$current_level] = $div = number_format(floor($amount) / $current_level,0);
          if($div)
          {
              $amount -= $current_level * $div;
          }
      }while($modulo &amp;&amp; next($levels));
  
  print_r($results);
  }
  
  foreach($amounts as $amount)
  {
   cheque_format($amount);
  }
  ?&gt;
  </code></pre>