0

我正在尝试将 a 转换为在 phparrayxml使用 ajson

jsonandarray工作正常,但是当我尝试将其转换为时,arrayxml不断收到错误消息。

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");
4

1 回答 1

0

也许是因为没有名为 array_to_xml() 的函数?你必须先定义它。

于 2013-10-05T18:44:47.550 回答