php - 如何打破一列来修复 php 表

标签 php php-7.4

我遇到了一个小问题,我无法破坏该表,因为我正在这些表中查找 16 列来创建 unicode 表... 目的是找到我必须在哪里打破列的线,就像那里一样:

<?php 

$columnas = 16;
$filas = 16;
$word= 0;
$contador = 0;

print "<table border=\"1\">\n";
print "<caption>ASCII</caption>\n";
print "<tbody>\n";
print "<tr>\n";

for ($j = 1; $j <= $columnas; $j++){
    if ($j%2 == 1){
        print "<th>Codigo</th>\n";
    }elseif ($j%2 == 0){
         print "<th>Valor</th>\n";
    }
}
print "</tr>";

for ($i = 1; $i <= $filas; $i++){

    for($i = 1; $i <= 50000; $i++,$contador){
        $unicodeChar = "&#{$i}";
        $contador--;
        print "<td>" .$i. "</td>\n";
        print "<td>".$unicodeChar."</td> \n";
    }   
    print "</tr>\n";
}   

print "</tbody>\n";
print "</table>\n";
 
?>

enter image description here

最佳答案

您在第一个循环中使用了模数,因此在第二个循环中再次使用它

print "</tr>";

print "<tr>";
for($i = 1; $i <= 50000; $i++){
    $unicodeChar = "&#{$i}";
    $contador--;
    print "<td>$i</td><td>$unicodeChar</td>\n";

    if ( $i % $columnas/2 ) == 0 ) {
        print "</tr><tr>\n";
    }
}   
print "</tr>\n";

关于php - 如何打破一列来修复 php 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70835705/

相关文章:

php - 预加载PHP脚本时 "Unknown type dependencies"是什么意思?

php - 如何在 PHP 中使用箭头函数?

php - 不能使用带有返回 void 类型提示的箭头函数

macos-catalina - 在 mac catalina 上启用 opcache,使用自制软件安装 php 7.4

与 LMS 兼容的 PHP 创作工具

php - 如何保护我的输入类型免受 firebug 和其他调试工具的影响

php - 将 CodeIgniter (PHP) 与 Backbone Js 混合使用

使用 Capifony 部署 Symfony2 项目时出现 PHP fatal error

php - 如何在 DSN 中指定用户名和密码?

php - yii2中where Between查询怎么写