snipt

Ctrl+h for KB shortcuts

PHP

fill number with 0s to desired length

// $n - desired length of string
str_pad($number,$n,"0",STR_PAD_LEFT);
https://snipt.net/embed/872fd11235ccbcfcbe1b65ab4901cd4d/
/raw/872fd11235ccbcfcbe1b65ab4901cd4d/
872fd11235ccbcfcbe1b65ab4901cd4d
php
PHP
2
2019-07-20T13:07:17
True
False
False
/api/public/snipt/2039/
fill-number-with-0s-to-desired-length
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">// $n - desired length of string</span> </span><span id="L-2"><a name="L-2"></a><span class="x">str_pad($number,$n,&quot;0&quot;,STR_PAD_LEFT);</span> </span></pre></div> </td></tr></table>
format, integer, php