cliveportman/code

Add leading zeroes using PHP

Useful for catalogue numbers, add leading zeros using str_pad:

$i = 56;
$cat = str_pad($i, 5, “0″, STR_PAD_LEFT);
echo $cat; // displays 00056