拆卸及维修;nbsp;在CURL请求之后使用PHP
我通过CURL从一个网站获取文本,但是它在原始网站的末尾,但是当我将其返回到我的网站时,这只是一个空间(在源代码中查看它之后),然而,即使使用str_replace、(string)、strval()等等,似乎也没有任何帮助 有人能帮忙吗 现行代码拆卸及维修;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($
$country = $s->fetchBetween('<dt>Country:</dt><dd>','</dd>', $result);
$country = strval($country);
$country = str_replace(" ", "", strval($country));
echo "start-{$country}-end";
exit;
请尝试以下方法
$country = str_replace("&nbsp;", "", strval($country));
试试这个
$string = 'x x ';
$pattern = '/ /';
echo preg_replace($pattern, '', $string);
最后使用$country=substr($country,0,-1);然而,我仍然很想知道这里到底发生了什么只是出于好奇,你试过
trim()
?
$string = 'x x ';
$pattern = '/ /';
echo preg_replace($pattern, '', $string);