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
No, there is no simple way.
function padIntegerPart($n, $len) { $intPart = (int)$n; return str_repeat('0', max(0, $len - 1 - floor(log($intPart, 10)))) . $n; }