printf %.4f for IP?
I would like to print an IP in fixed way.. example
12.12.1.0
would tured to
012.012.001.000
what's t开发者_开发技巧he best method do it ?
printf("%.4f.%.4f.%.4f.%.4f",$ip);
?
With zero padding:
$ip = "12.12.1.0";
vprintf("%03d.%03d.%03d.%03d", explode('.', $ip));
精彩评论