PHP integer part padding

前端 未结 5 2003
北恋
北恋 2020-12-21 04:32

I need to pad the integer part with 0, the integer part must be at least 2 characters

str_pad( 2    ,2,\"0\",STR_PAD_LEFT);// 02 -> works
str_pad( 22   ,2         


        
5条回答
  •  遥遥无期
    2020-12-21 04:55

    You can also use printf() functions to pad the integer :

    Something like (codepad):

提交回复
热议问题