Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.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
拆卸及维修;nbsp;在CURL请求之后使用PHP_Php_Html_Curl - Fatal编程技术网

拆卸及维修;nbsp;在CURL请求之后使用PHP

拆卸及维修;nbsp;在CURL请求之后使用PHP,php,html,curl,Php,Html,Curl,我通过CURL从一个网站获取文本,但是它在原始网站的末尾,但是当我将其返回到我的网站时,这只是一个空间(在源代码中查看它之后),然而,即使使用str_replace、(string)、strval()等等,似乎也没有任何帮助 有人能帮忙吗 现行代码 $country = $s->fetchBetween('<dt>Country:</dt><dd>','</dd>', $result); $country = strval($

我通过CURL从一个网站获取文本,但是它在原始网站的末尾,但是当我将其返回到我的网站时,这只是一个空间(在源代码中查看它之后),然而,即使使用str_replace、(string)、strval()等等,似乎也没有任何帮助

有人能帮忙吗

现行代码

    $country = $s->fetchBetween('<dt>Country:</dt><dd>','</dd>', $result);
    $country = strval($country);
    $country = str_replace("&nbsp;", "", strval($country));
    echo "start-{$country}-end";
    exit;

请尝试以下方法

$country = str_replace("&amp;nbsp;", "", strval($country));
试试这个

$string = 'x&nbsp;&nbsp;&nbsp;&nbsp;x ';
$pattern = '/&nbsp;/';
echo preg_replace($pattern, '', $string);   

最后使用$country=substr($country,0,-1);然而,我仍然很想知道这里到底发生了什么只是出于好奇,你试过
trim()
$string = 'x&nbsp;&nbsp;&nbsp;&nbsp;x ';
$pattern = '/&nbsp;/';
echo preg_replace($pattern, '', $string);