1. cliveportman
  2. /code
  3. /add-leading-zeroes-using-php

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