Created
March 23, 2015 07:23
-
-
Save ety001/f719f4725349c550a329 to your computer and use it in GitHub Desktop.
处理富文本为App友好显示
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* author ety001 | |
* desc 处理富文本为APP可显示的形式 | |
* return str | |
*/ | |
function i_remove_space_and_htmltag($str) | |
{ | |
$str = preg_replace('/(<\/[\w]+>)/', "\r\n", $str); | |
$str = str_replace('<br>', "\r\n", $str); | |
$str = str_replace('<hr>', "\r\n", $str); | |
$str = str_replace(' ', " ", $str); | |
$str = strip_tags($str); | |
$str = preg_replace("/([\r\n]+)/", "\r\n", $str); | |
$str = htmlspecialchars_decode($str); | |
return $str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment