If php has only one digit, add a 0?

hypothetical

$a = 1;
$b = 10;

suppose that $an is only one digit, then add 0 before it, and change 01
$b has ten digits, so do not add
this can be reached by what function?

Mar.03,2021

str_pad


str_pad($a,2,"0",STR_PAD_LEFT)

  • number of judgment digits
  • splicing

you can write a function yourself, using the knowledge of concatenating strings

.
Menu