如何建立指定格式的数组结果

时间:2019-05-14 10:06:42

标签: php

我正在设置API格式,我希望结果采用特定格式

下面是我的输出数组,请帮帮我。

 Array
    (
     [status] => 1
     [content] => Array
     (
        [0] => Array
            (
                [code] => 100
                [name] => FAMILY
                [lname] => test
                [lcode] => 123
            )

        [1] => Array
            (
                [code] => 100
                [name] => FAMILY
                [lname] => test1
                [lcode] => 
            )

        [2] => Array
            (
                [code] => 110
                [name] => FAMILY 02
                [lname] => 
                [lcode] => 
            )
        )
)

我的预期结果格式如下:

   {
     "list": [
               {
                 "code": "100",
                 "name": "Family",
                  "lCust": [
                        {
                          "lcode": "LC00045",
                          "lname": "test"
                        },
                        {
                           "lcode": "LC00045",
                           "lname": "test1"
                        }
                     ]
                },
                 {
                   "code": "110",
                   "name": "FAMILY 02",
                   "lCust": []
                  }
          ]
     }

请提供一种解决方案。

0 个答案:

没有答案