title: PHP: How to add leading zeros/zero padding to float via sprintf()?
body: <p>I'm using <a href="http://php.net/manual/en/function.sprintf.php" rel="noreferrer">sprintf()</a> to get a formatted string of some float numbers with a certain precision. In addition, I wanted to add leading zeros to make all numbers even in length. Doing that for integers is <a href="https://stackoverflow.com/a/1699980/413531">pretty straight forward</a>:</p>
  
  <pre><code>sprintf('%02d', 1);
  </code></pre>
  
  <p>This will result in <code>01</code>. However, trying the same for a float with precision doesn't work:</p>
  
  <pre><code>sprintf('%02.2f', 1);
  </code></pre>
  
  <p>Yields <code>1.00</code>.</p>
  
  <p>How can I add leading zeros to a float value?</p>