php到JSON中的特殊字符和新行

php到JSON中的特殊字符和新行,php,Php,我想打印一个干净的JSON响应,显示所有特殊字符、段落、换行符等。。我正在使用此功能执行所有必要的操作,并清理有关粗体文本等的响应。。基本上,我所需要做的就是每次在文本中检测到\r时,为这个特定的JSON响应在响应中添加一个空行。有办法吗 function retiraTagHTML($textoComTag){ $textoComTag = html_entity_decode($textoComTag); $textoComTag = preg_replace('/\n{

我想打印一个干净的JSON响应,显示所有特殊字符、段落、换行符等。。我正在使用此功能执行所有必要的操作,并清理有关粗体文本等的响应。。基本上,我所需要做的就是每次在文本中检测到\r时,为这个特定的JSON响应在响应中添加一个空行。有办法吗

function retiraTagHTML($textoComTag){
     $textoComTag = html_entity_decode($textoComTag);
     $textoComTag = preg_replace('/\n{2,}/', "</p><p>", trim($textoComTag));
     $textoComTag = preg_replace('/\n/', '<br>',$textoComTag);
     return strip_tags($textoComTag, '<(.*?)>');
}
函数retiraTagHTML($textococTag){
$textoComTag=html\u entity\u decode($textoComTag);
$textoComTag=preg_replace('/\n{2,}/',“

”,trim($textoComTag)); $textoComTag=preg_replace(“/\n/”、“
”、$textoComTag); 返回带标签($textoComTag,”); }

这就是我所需要的

function removeHTMLtag($textWithTag){
    $textWithoutTag = strip_tags($textWithTag, '<(.*?)>');
    $textWithoutTag = html_entity_decode($textWithoutTag );
    return $textWithoutTag ;
}
函数removeHTMLtag($textWithTag){
$textWithoutTag=带标签($textWithTag,”);
$textWithoutTag=html\u entity\u decode($textWithoutTag);
返回$text,不带标签;
}

换行符可以是
CRLF
\r\n
)、
LFCR
\n\r
)、
LF
\r
)或
CR
\n
)。你需要得到所有这些。例如,通过
(\r\n | \n\r | \r | \r | \n)
而不是
\n
'/\r+/'
将匹配所有Unicode换行符序列。有一种方法可以轻松地转换所有html,就像html实体解码一样?@H2Oooooooo操作系统使用
\n\r
?@Gumbo没有当前的操作系统,但是。