Quick Math question...
Posted: Sat Jun 04, 2005 10:31 am
Anyone know how to turn one digit numbers like '1' into three digit numbers like '001' using a function? So, for example 81 would become 081.
Larry.
Larry.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
if ($var <= 9 && $var >= 0) {
$var = "0".$var;
} elseif ($var <= 99) {
$var = "00".$var;
}Code: Select all
printf( "%04d", $strout_data );printf, also less redundant code with printf.Ambush Commander wrote:Hmm.. has anyone ever checked which is faster?