PHP& Code Snippets18 Mar 2005 02:40 pm
sprintf - how to pad numbers with leading zeros
How to pad numbers with leading zeros using PHP:
Example #1:
$num = 5;
$count = sprintf(”%05s”,$num); // produces ‘00005′
Example #2:
$num = 5310;
$count = sprintf(”%05s”,$num); // produces ‘05310′
March 18th, 2005 at 9:10 pm
[…] to have this directory of snippets mirrored on Webmaster Cookbook (for younger students). Here’s an example of they type of code snippets that will be found there. All snippets will be free t […]