我对删除表格单元格中的空格有疑问... 即我有那个表格单元格
+------------+
+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>" . "● ".iconv("cp1257", "utf-8", $tabled_mani[$i]) . "</td>";
} else {
// second column
$table .= "<td>" . "● ".iconv("cp1257", "utf-8", $tabled_mani[$i]) . "</td></tr>";
}
$counter++;
}
$table .= "</table>";
echo $table;
所以通过这段代码,我生成了一个包含两列的表格,所有内容都是从数组中动态添加的。
有什么建议吗?
附言line-height
在 css 中设置为 5px,我也尝试更改 <td>
自动高度,它也没有帮助。
在输出字符串或 HTML 中,表列中没有空格。
最佳答案
看起来您的问题可能是您输入的一些 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/