Home  >  Article  >  Backend Development  >  如何批量打印同时带字母和数字四位数

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

WBOY
WBOYOriginal
2016-06-13 11:53:021078browse

怎么批量打印同时带字母和数字四位数。
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).'
';
}
?>

Statement:
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