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

This question already has an answer here:

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
197
задан Ben 13 April 2011 в 18:44
поделиться