lxy777 发表于 2017-4-9 10:46:47

php-html 动态表格分行-数据结构剖析

$files = scandir('.');
echo '<table align="center" border="1" cellpadding="5" cellspacing="0" width="800" style="min-width:444px;">';
$counter = 1;
$each_columns = 4;
foreach($files as $file_num => $file) {
if($file_num > 1){
$file = iconv("GBK","UTF-8",$file);//或者 iconv("gb2312","UTF-8",$value);
if(is_dir($file)){
$file = '<a href="'.$file.'">'.$file.'</a>';
if($counter % $each_columns == 1) {
echo '<tr>';
}
echo '<td>'.$counter.$file.'</td>';
if($counter % $each_columns == 0){
echo '</tr>';
}
$counter++;
}
}
}
$counter = $counter-1;
if($counter % $each_columns != 0){
for($i = 0; $i < ($each_columns-($counter)%$each_columns); $i++){
echo "<td>&nbsp;</td>";
}
}
echo '</table>';
  注:本程序动态分行理念适合所有动态语言,js,java,php···
页: [1]
查看完整版本: php-html 动态表格分行-数据结构剖析