Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 删除空格后奇怪的换行符_Php_Regex_Curl - Fatal编程技术网

Php 删除空格后奇怪的换行符

Php 删除空格后奇怪的换行符,php,regex,curl,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_

我使用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\u replace(数组(“\r\n”、“\r”)、“\n”、$content)删除换行符但它不起作用。

有什么想法吗?

告诉我,你真的想删除所有空白,而不仅仅是压缩重复的空白吗?压缩重复的空白是什么意思?