当前位置:Gxlcms > PHP教程 > 如何批量打印同时带字母和数字四位数

如何批量打印同时带字母和数字四位数

时间:2021-07-01 10:21:17 帮助过:10人阅读

怎么批量打印同时带字母和数字四位数。
00x0
00x1
00x2
00x3
........
99x9

用什么方法打印出这样的效果?

------解决方案--------------------
$arr = range(0, 999);
$b = array_map('change', $arr);
function change($n){
$new = str_pad($n, 3,'0',STR_PAD_LEFT );
return substr($new, 0,2)."x".substr($new, 2);
}
var_dump($b);

------解决方案--------------------

for($i=0; $i<=999; $i++){
echo str_pad((int)($i/10),2,'0',STR_PAD_LEFT).'x'.($i%10).'
';
}
?>

人气教程排行