0

我有以下代码,我正在尝试在 $query 变量中进行正则表达式替换,并且我需要将所有出现的“Hello”替换为“Bye”。这段代码有什么问题?

<?php

ini_set("default_socket_timeout", 116000);

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://www.mysite.com.br/index.php?option=com_xxxx&format=xml');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
$query = curl_exec($curl_handle);
curl_close($curl_handle);


if (strlen($query) > 95000){
echo "OK";
substr_replace ($query ("hello","bye",0));
file_put_contents('/home/myuser/mysite.com/xml/file.xml',$query);
} 
else 
{
echo "Error";
}

?>
4

1 回答 1

2

str_replace实际上是您要查找的命令;

$query = str_replace ("hello","bye",$query);
于 2013-10-07T17:28:59.637 回答