标签: php json hierarchy
如何生成json和php的层次结构,如下图所示?
json
php
答案 0 :(得分:0)
你可以试试这个
阵列:
$arr = array( "X1" => array( "X2" => array("X4", "X5"), "X3" => array("X6", "X7") ) );
JSON编码:
echo $json = json_encode($arr); //{"X1":{"X2":["X4","X5"],"X3":["X6","X7"]}}