PHP prepend leading zero before single digit number, on-the-fly [duplicate]

PHP – Is there a quick, on-the-fly method to test for a single character string, then prepend a leading zero?

Example:

$year = 11;
$month = 4;

$stamp = $year.add_single_zero_if_needed($month);  // Imaginary function

echo $stamp; // 1104

3 Answers
3

Leave a Comment