$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $realhost);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $regstring);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,180);
$arg1=curl_exec($ch);
if($queue_debug_mode=="1"){echo "Debug (".curl_error($ch)."): ";print_r(htmlentities($arg1));}
curl_close($ch);
print_r($arg1);输出结果为:
[RESPONSE]
code = 541
description = Command failed
reason = Nameserver requeired.请问怎么把curl_exec的结果转化为array(),我可以这样使用$response["code"]或者$response["description"]
curl_setopt($ch, CURLOPT_URL, $realhost);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $regstring);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,180);
$arg1=curl_exec($ch);
if($queue_debug_mode=="1"){echo "Debug (".curl_error($ch)."): ";print_r(htmlentities($arg1));}
curl_close($ch);
print_r($arg1);输出结果为:
[RESPONSE]
code = 541
description = Command failed
reason = Nameserver requeired.请问怎么把curl_exec的结果转化为array(),我可以这样使用$response["code"]或者$response["description"]
$response=array();
$output = explode("\n",$arg1);
foreach($output as $val)
{
$tmp=@explode("=",$val);
if(count($tmp)>1)
{
$response[trim($tmp[0])]=trim($tmp[1]);
}
}
param1=value1¶m2=value2....
这样直接用parse_str就可以了