-2

My question subject can be seen easy, but i need something different.

$string = rand(1,99999) // echo 1 

But my need it should

$string = rand(---?----) //echo 00001 - Always 5 characters..

For example when $string echo "23" it should write 00023 , if the $string writes 2 character left side will be 3times zero - 3 charachter, should write left side 2 times zero - 4 character , should write 1 time zero... Logic is always 5 character...

Bbbb
  • 69
  • 2
  • 10

1 Answers1

0

I found the solution...

str_pad($string, 5, "0", STR_PAD_LEFT);
Bbbb
  • 69
  • 2
  • 10