3000 explained code solutions for 75 technologies


phpFormat number with leading zeros


str_pad($num, 10, '0', STR_PAD_LEFT);ctrl + c
str_pad

will add specified amount of characters to the string

$num

number to add zeros to

10

total length of resulting number with zeros

'0'

symbol to add to number (zero in our case)

STR_PAD_LEFT

add zeros to the left side of the number