首页 >php教程 >php手册 >php 数组 数字 补零

php 数组 数字 补零

WBOY
WBOY原创
2016-06-06 19:49:081196浏览

$hour_list = range(0,24); foreach($hour_list as $key=$val){ $hour_list[$key] = str_pad($val, 2, "0", STR_PAD_LEFT); } var_dump($hour_list); $hour_list = range(0,24); foreach($hour_list as $key=$val){ $hour_list[$key] = sprintf('%02d',$val)

 

$hour_list = range(0,24);
foreach($hour_list as $key=>$val){
$hour_list[$key] = str_pad($val, 2, "0", STR_PAD_LEFT);
}
var_dump($hour_list);

 


$hour_list = range(0,24);
foreach($hour_list as $key=>$val){
$hour_list[$key] = sprintf('%02d',$val);
}
var_dump($hour_list);

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn