php - HTML 删除表格行中的空格

标签 php html css

我对删除表格单元格中的空格有疑问... 即我有那个表格单元格

+------------+
+testtesttest+
+            +
+            +
+------------+

但是如果我在文本中有很多符号,那一切都很好(即):

+-------------+
+aksjhdfgasjhd+
+asdfasdfafdgh+
+asdfasdfasdfa+
+-------------+

所有文本和表格单元格均由 php 代码生成:

$table = "<table cellspacing='0' width='520' border='1' id='tbl_table'>";
    $counter = 0;
    $total = count($tabled_mani);
    if ( $total % 2 != 0 ) {
        $total += 1;
    }

    // loop through the array
    for ($i=0; $i < count($tabled_mani); $i++) {
        if ( $counter % 2 == 0 ) {
            // first column
            $table .= "<tr><td>" . "&#x25CF;&nbsp;".iconv("cp1257", "utf-8", $tabled_mani[$i]) . "</td>";
        } else  {
            // second column
            $table .= "<td>" . "&#x25CF;&nbsp;".iconv("cp1257", "utf-8", $tabled_mani[$i]) . "</td></tr>";
        }
        $counter++;
    }
$table .= "</table>";

echo $table;

所以通过这段代码,我生成了一个包含两列的表格,所有内容都是从数组中动态添加的。

有什么建议吗?

附言line-height在 css 中设置为 5px,我也尝试更改 <td>自动高度,它也没有帮助。 在输出字符串或 HTML 中,表列中没有空格。

编辑 1: enter image description here

最佳答案

看起来您的问题可能是您输入的一些 HTML(可能是一大堆 <p> 标签)。而不是 iconv("cp1257", "utf-8", $tabled_mani[$i])尝试 strip_tags(iconv("cp1257", "utf-8", $tabled_mani[$i])) .

关于php - HTML 删除表格行中的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41672403/

相关文章:

javascript - 从 Google 搜索结果中提取数据

javascript - 在 Laravel Blade 中的 foreach 循环上使用 javascript 函数

javascript - html5 视频无法在 iPad 中播放

javascript - 将 Html 表单信息存储到 JS 数组中

html - 如何用百分比高度填充图像?

css - ie7 条件覆盖不起作用

javascript - 单个占位符中是否可能有多种文本颜色?

php - Vertica 和 PDO 准备好的语句

php - 将包含 case 语句的 MySql 查询转换为 codeigniter 事件记录查询

javascript - innerHTML 不显示数据库中的 html