Share:
Copy code The code is as follows:
function jsformat($str)
{
$str = trim($str);
$str = str_replace('\s\s', '\s', $str);
$str = str_replace(chr(10), '', $str) ;
$str = str_replace(chr(13), '', $str);
$str = str_replace(' ', '', $str);
$str = str_replace('\' , '\\', $str);
$str = str_replace('"', '\"', $str);
$str = str_replace('\'', '\\'', $str);
$str = str_replace("'", "'", $str);
return $str;
}
Needless to say, use it. Just call jsformat($str) directly
http://www.bkjia.com/PHPjc/323283.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323283.htmlTechArticleShare it: Copy the code as follows: function jsformat($str) { $str = trim($str); $str = str_replace('\s\s', '\s', $str); $str = str_replace(chr(10), '', $str); $str = str_...