Json到数组到XML[Php]
我试图在php中使用Json到数组到XML[Php],php,xml,json,Php,Xml,Json,我试图在php中使用json将数组转换为xml json和array工作正常,但是当我尝试将array转换为xml时,我一直收到一个错误 Call to undefined function array_to_xml() 这是json {"host":"127.0.0.1","username":"root","password":"something","dbname":"something","table":"something"} Json到`数组 $json = json_decod
json
将数组转换为xml
json
和array
工作正常,但是当我尝试将array
转换为xml
时,我一直收到一个错误
Call to undefined function array_to_xml()
这是json
{"host":"127.0.0.1","username":"root","password":"something","dbname":"something","table":"something"}
Json到`数组
$json = json_decode(file_get_contents('something.json'), true);
$info = array(
$json['host'],
$json['username'],
$json['password'],
$json['dbname'],
);
数组到xml
simplexml_load_string(array_to_xml($json, new SimpleXMLElement('<connection/>'))->asXML()) or die("can't read");
simplexml\u load\u字符串(数组到xml($json,新的simplexmlement(“”))->asXML())或die(“无法读取”);
可能是因为没有名为array_to_xml()的函数?你必须先定义它。它应该是一个评论,真的。对不起,声誉不够。不管怎样,我还是想帮你。你是在使用库还是其他什么东西吗?没有内置的php函数名为array\u to\u xml
,我明白了。那么,有没有一种方法可以实现这一点呢?你可以试着看看他们使用DOM接口来创建xml