2

我想从字符串中删除 ¶ 段落标记。我已经尝试过 strip_tags 和 preg_replace,但它不起作用。该字符串位于 mysql 记录中。在将其保存到数据库之前和显示之前,我尝试将其删除,但似乎没有任何效果。

任何帮助表示赞赏。

4

2 回答 2

5

用 ¶ 显示你的真实字符串,因为这很好用:

<?php

$string = 'Hi¶ this is a string with a paragraph¶';
$string = str_replace( "¶", "", $string );
echo $string;

?>

输出

Hi this is a string with a paragraph
于 2012-07-20T09:18:39.690 回答
1

这对我有用

$mystring = preg_replace( '/\s+/', ' ', $mystring);

从字符串中删除白色间距

于 2012-07-23T08:22:07.323 回答