我有如下内容.
我希望将<pre></pre>
其转换为<p> </p>
.但我无法实现它.以下是一个例子
$content = "<pre>This is a pre text I want to convert it to paragraphs ";
print_r(str_replace(array('<pre>', '</pre>', ' '),array('<p>', '</p>', '<br/>'),htmlspecialchars($content)));
Run Code Online (Sandbox Code Playgroud)
但我得到了输出.有人可以帮我解决.提前致谢
我有桌子 tr设置有边框。我想从tr中删除最后一个td边框。下面是示例
<table>
<thead>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
</tr>
</thead>
<tbody>
<tr style="border-right: 1px solid #C1DAD7;border-bottom: 1px solid #C1DAD7;">
<td> adsd </td>
<td> adsd </td>
<td> adsd </td>
<td> adsd </td> <!-- I want to remove the border from this -->
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
任何答案将不胜感激
我有以下代码,其中在foreach循环中的html实体中添加了一个箭头。该html实体位于span标记中。我要删除最后一个箭头。
$btn = '<div style="margin: 5px;">';
if (count($rslt) > 0) {
foreach ($rsltas as $key => $val) { //added as here
$btn .= "<a class='btn btn-md' href='index.php?target=$trgtName#" . trim(substr($val, 0, strpos($val, '-'))) . "'>" . $val . "</a><span style='font-size:50px'>→</span>";
}
}
$btn = rtrim($btn, '<span>→</span>');
print $btn . "</div>";
Run Code Online (Sandbox Code Playgroud)
我尝试过,rtrim
但这会改变整个html页面。还有其他解决方案可以删除php中的最后一个html元素foreach
。