Php 数组到XML在过程中间失败
正如您在下面所看到的,所有内容都与Php 数组到XML在过程中间失败,php,xml,simplexml,Php,Xml,Simplexml,正如您在下面所看到的,所有内容都与uid和pwd元素密切相关。突然用价值观俯冲某地。我是不是遗漏了什么 原始代码是 代码: $array = array('table'=>'users', 'operation'=>'insert', 'uid'=>'yoyo', 'pwd'=>'123'); $output = serialize($array); $xml = new SimpleXMLElement('<root/>'); array_walk_rec
uid
和pwd
元素密切相关。突然用价值观俯冲某地。我是不是遗漏了什么
原始代码是
代码:
$array = array('table'=>'users', 'operation'=>'insert', 'uid'=>'yoyo', 'pwd'=>'123');
$output = serialize($array);
$xml = new SimpleXMLElement('<root/>');
array_walk_recursive(unserialize($output), array($xml, 'addChild'));
echo $xml->asXML();
<?xml version="1.0"?>
<root>
<users>table</users>
<insert>operation</insert>
<yoyo>uid</yoyo>
<123>pwd</123>
</root>
$array=array('table'=>'users','operation'=>'insert','uid'=>'yoyo','pwd'=>'123');
$output=序列化($array);
$xml=新的SimpleXMLElement(“”);
数组_walk_递归(非序列化($output),数组($xml,'addChild');
echo$xml->asXML();
结果:
$array = array('table'=>'users', 'operation'=>'insert', 'uid'=>'yoyo', 'pwd'=>'123');
$output = serialize($array);
$xml = new SimpleXMLElement('<root/>');
array_walk_recursive(unserialize($output), array($xml, 'addChild'));
echo $xml->asXML();
<?xml version="1.0"?>
<root>
<users>table</users>
<insert>operation</insert>
<yoyo>uid</yoyo>
<123>pwd</123>
</root>
桌子
活动
液体
pwd
根据您的需要,您必须翻转阵列,因此请尝试
换线
$output = serialize($array);
与