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

This question already has answers here: Formatting a number with leading zeros in PHP [duplicate] (11 answers) Closed 3 years ago. 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 … Read more