删除空格后出现奇怪的换行符

时间:2012-09-05 12:35:04

标签: php regex curl

我正在使用cURL来获取网站的内容。我想从字符串中删除所有空格和换行符。这就是我正在做的事情:

// Getting the content
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($curl_handle);
curl_close($curl_handle);

// Removing html tags
$content = strip_tags($content);

// Removing whitespaces
$content = preg_replace('/\s+/', '', $content);

当我回复内容时,我会在这些特殊字符之后获得换行符:=),.?} 我尝试使用str_replace(array("\r\n", "\r"), "\n", $content);删除换行符,但它不起作用。 有什么想法吗?

0 个答案:

没有答案