$status = 0;
$message = "公司参数不正确,请核查相关代码。";
// heredoc or nowdoc .
$message_xml = <<<EOD
<xml>
<status>{$status}</status>
<message>{$message}</message>
</xml>
EOD;
//$xml = "<xml>" . "<status>{$status}</status>";
//$message_xml;
// 将 xml 格式数据,通过 json,转换为 PHP 数组
$xml = simplexml_load_string($message_xml);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
var_dump($array);
网友评论