我有存储在数据库中的代码,并且在php中以html形式显示
我尝试了preg_replace,nl2br以及所有其他方法,但仍未获得预测的输出。
假设我有
这样的字符串 this is the test
$postContent = $getsingleviewodetail->epost_content;
$postContent = nl2br($postContent);
{!!substr($postContent,0,200)!!}
在测试前的上述句子中,我们有很多空格,我想在我的网页中显示这些空格。
答案 0 :(得分:1)
执行以下操作:
strcmp
p {
white-space: pre
}
答案 1 :(得分:0)
运行良好
在php
$string = "this is the test <br>test";
$string = preg_replace('#<br\s*/?>#', "\n", $string);
您认为
<pre>{{$string}}</pre>
答案 2 :(得分:-1)
<div class="dis_txt" style="white-space: pre;">
<a target="_blank" href="https://vdo.matrubharti.com/bites/hashtag/whythis">#whythis</a> <br>
<br>
why this is not working now -> why this<br>
<br>
why this is not working n
<div id="video_content" class="collapse in" aria-expanded="true" style="">
ow -> why this<br>
<br>
why this is not working now -> why this<br>
<br>
why this is not working now -> why this<br>
<br>
why this is not working now -> why this<br>
why this is not working now -> why this<br>
why this is not working now -> why this<br>
为什么现在不起作用->为什么这样