前言

不说废话,直接上干货√

参考格式如下:

[
  {
    "text": "北京市",
    "value": "110000",
    "children": [
      {
        "text": "北京城区",
        "value": "110100",
        "children": [
          { "text": "东城区", "value": "110101", "alpha": "d" },
          { "text": "西城区", "value": "110102", "alpha": "x" },
          { "text": "朝阳区", "value": "110105", "alpha": "c" },
          { "text": "丰台区", "value": "110106", "alpha": "f" },
          { "text": "石景山区", "value": "110107", "alpha": "s" },
          { "text": "海淀区", "value": "110108", "alpha": "h" },
          { "text": "门头沟区", "value": "110109", "alpha": "m" },
          { "text": "房山区", "value": "110111", "alpha": "f" },
          { "text": "通州区", "value": "110112", "alpha": "t" },
          { "text": "顺义区", "value": "110113", "alpha": "s" },
          { "text": "昌平区", "value": "110114", "alpha": "c" },
          { "text": "大兴区", "value": "110115", "alpha": "d" },
          { "text": "怀柔区", "value": "110116", "alpha": "h" },
          { "text": "平谷区", "value": "110117", "alpha": "p" },
          { "text": "密云区", "value": "110118", "alpha": "m" },
          { "text": "延庆区", "value": "110119", "alpha": "y" }
        ],
        "alpha": "b"
      }
    ]
  },
]
<?php
$data = [
    [
        "text" => "北京市",
        "value" => "110000",
        "children" => [
            [
                "text" => "北京城区",
                "value" => "110100",
                "children" => [
                    [
                        "text" => "东城区",
                        "value" => "110101",
                        "alpha" => "d"
                    ],
                    [
                        "text" => "西城区",
                        "value" => "110102",
                        "alpha" => "x"
                    ],
                    [
                        "text" => "朝阳区",
                        "value" => "110105",
                        "alpha" => "c"
                    ]
                ],
                "alpha" => "b"
            ]
        ]
    ],


GeorgieのBlog,分享生活的点点滴滴,分享代码干货