日期:2014-05-16 浏览次数:20505 次
for ($i=1;$i<=99;$i++){
$arr[]=sprintf("aa%02d",$i);
}
print_r($arr);
[align=left] //字符串二维数组,每是个字符串为一组,也即每十个字符串组成一个数组
$strarr = array();
//计数器,用来计算$strarr内数组元素的个数
$count = 0;
//生成想要的字符串数组
for ( $i = 1; $i <= 99; $i++ ) {
//每生成十个字符串,则计数器$count自加1
if( ($i - 1 ) % 10 === 0 ) $count++;
//将1~9内的数字转为0i格式的字符串
$stri = ( $i >= 1 && $i <= 9) ? ('0'.$i) : $i;
$strarr[$count - 1][] = 'aa'.$stri;
}
echo '<pre>';
print_r($strarr);
echo '</pre>';[/align]
<?php
$arr = array();
for($i=1; $i<100; $i++){
$arr[(int)($i-1)/10][] = sprintf("aa%s", str_pad($i,2,'0',STR_PAD_LEFT));
}
print_r($arr);
?>
for($i=0; $i<100; $i++) $res[] = sprintf('aa%02d<br>', $i);
echo join("<p>\n", array_map('join', array_chunk($res, 10)));
aa00<br>aa01<br>aa02<br>aa03<br>aa04<br>aa05<br>aa06<br>aa07<br>aa08<br>aa09<br><p>
aa10<br>aa11<br>aa12<br>aa13<br>aa14<br>aa15<br>aa16<br>aa17<br>aa18<br>aa19<br><p>
aa20<br>aa21<br>aa22<br>aa23<br>aa24<br>aa25<br>aa26<br>aa27<br>aa28<br>aa29<br><p>
aa30<br>aa31<br>aa32<br>aa33<br>aa34<br>aa35<br>aa36<br>aa37<br>aa38<br>aa39<br><p>
aa40<br>aa41<br>aa42<br>aa43<br>aa44<br>aa45<br>aa46<br>aa47<br>aa48<br>aa49<br><p>
aa50<br>aa51<br>aa52<br>aa53<br>aa54<br>aa55<br>aa56<br>aa57<br>aa58<br>aa59<br><p>
aa60<br>aa61<br>aa62<br>aa63<br>aa64<br>aa65<br>aa66<br>aa67<br>aa68<br>aa69<br><p>
aa70<br>aa71<br>aa72<br>aa73<br>aa74<br>aa75<br>aa76<br>aa77<br>aa78<br>aa79<br><p>
aa80<br>aa81<br>aa82<br>aa83<br>a