开发者

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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜