title: Why is the number formatting abnormal?
body: <p>So i wanted to display a counter with each char wrapped in a tag and also add a thousands seprator.</p>
  
  <p>The number must be atleast 3 char long.</p>
  
  <p><strong>Case 1:</strong></p>
  
  <p>I took a number <code>12</code></p>
  
  <p><em>the code:</em></p>
  
  <pre><code>$number = 12 //number 12
  $number = number_format($number, 0, '', ','); //add a thousand seprator
  $number = str_pad($number,3,0,STR_PAD_LEFT); //pad if length less than 3
  $counter = "";
  foreach (str_split($number) as $key =&gt; $digit) {
      $counter .= '&lt;b&gt;' . $digit . '&lt;/b&gt;';
  }
  </code></pre>
  
  <p>Output: <code>012</code> (ignoring the <code>&lt;b&gt;</code> tag)</p>
  
  <p><strong>Case 2:</strong></p>
  
  <p>I took a number <code>1234</code></p>
  
  <p><em>the code:</em></p>
  
  <pre><code>$number = 1234 //number 1234
  $number = number_format($number, 0, '', ','); //add a thousand seprator
  $number = str_pad($number,3,0,STR_PAD_LEFT); //pad if length less than 3
  $counter = "";
  foreach (str_split($number) as $key =&gt; $digit) {
      $counter .= '&lt;b&gt;' . $digit . '&lt;/b&gt;';
  }
  </code></pre>
  
  <p>Output: <code>1,234</code> (ignoring the <code>&lt;b&gt;</code> tag)</p>
  
  <p><strong>Case 3:</strong></p>
  
  <p>I took a number <code>0012</code></p>
  
  <p><em>the code:</em></p>
  
  <pre><code>$number = 0012 //number 0012
  $number = number_format($number, 0, '', ','); //add a thousand seprator
  $number = str_pad($number,3,0,STR_PAD_LEFT); //pad if length less than 3
  $counter = "";
  foreach (str_split($number) as $key =&gt; $digit) {
      $counter .= '&lt;b&gt;' . $digit . '&lt;/b&gt;';
  }
  </code></pre>
  
  <p>Output: <code>010</code> (ignoring the <code>&lt;b&gt;</code> tag)</p>
  
  <hr>
  
  <p>So what went wrong in <strong>case 3</strong>?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>How to avoid this?</p>