Home > php教程 > php手册 > php 数组 数字 补零

php 数组 数字 补零

WBOY
Release: 2016-06-06 19:49:08
Original
1196 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template