php数组转xml
- 代码:
'; $xml .= change($arr); return $xml; } function change($source) { $string=""; foreach($source as $k=>$v){ $string .="<".$k.">"; if(is_array($v) || is_object($v)){ $string .= change($v); }else{ $string .=$v; } $string .="".$k.">"; } return $string; }
- 测试:
$arr = array( 'name' => array( 'a' => 'aa', 'b' => 'bb' ) ); $xml = arraytoxml($arr); echo $xml;
- 输出:
aabb
名称栏目:php数组转xml
链接地址:http://myzitong.com/article/jpscpd.html