我正在使用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);
删除换行符,但它不起作用。
有什么想法吗?