【发布时间】:2021-06-11 01:40:34
【问题描述】:
我从数据库中检索了一个 HTML 字符串,需要将所有  s' 更改为空格
<p> C G Am</p><p>C G Am F</p>
所以我想将 更改为空格,这样我就可以在前置元素中使用
<pre></pre>
如下
<pre >
//here i needed to insert the converted string
//for example
C G Am F
C G F C/E Dm C
</pre>
我需要在 PHP、JS/Jquery 中执行此操作的解决方案
请帮我解决这个问题
我试过了
$nbsp = html_entity_decode(" ");
$s = html_entity_decode("<p> C G Am</p>");
$s = str_replace($nbsp, " ", $s);
我试过这个,但这会将所有 nbsp 替换为一个空格
【问题讨论】:
-
到目前为止你尝试了什么?
-
$nbsp = html_entity_decode(" "); $s = html_entity_decode("
C   ; G Am
"); $s = str_replace($nbsp, " ", $s);我试过了,但这会将所有 nbsp 替换为一个空格 -
请编辑您的问题并在此处添加您的代码。
-
如果您在刀片模板中显示,则有显示 HTML 代码的语法。
{!! $html !!}
标签: javascript php html