如何使用PHP从JSON获取所有密钥?

时间:2018-09-20 10:20:02

标签: php json

如何获取下面JSON中的所有键, 我可以编写一个可以从这两个JSON中获取所有键名的函数吗?

JSON 1:

{
   "0":[
      {
         "Start Date#SingleLineText":"2018-06-25",
         "End Date #SingleLineText":"2018-06-30",
         "MDO#DropDown":"8.Abhijeet Kale",
         "Focus Categories #DropDown":"Bulk Fertiliser",
         "Focus Product #DropDown":"DAP",
         "Focus Crop#DropDown":"Cotton",
         "No of Spot Meetings #SingleLineText":"10",
         "Dealer Relations#DropDown":"Yes",
         "Collaterals#DropDown":"Yes",
         "Visibility #DropDown":"No",
         "Equipments #DropDown":"No"
      }
   ],
   "Dealer Relations List #CheckBox":{
      "Dealer Relations List ":"[\"Bunting\",\"\",\"\",\"\",\"Dummy bags -danglers\",\"\",\"\"]"
   },
   "Collaterals List #CheckBox":{
      "Collaterals List ":"[\"Leaflets\",\"\",\"Posters\",\"\"]"
   }
}

JSON 2:

[
   [
      {
         "Discussion with a dealer#Header":[
            ""
         ],
         "Collection discussion done?#RadioButton":[
            "Yes"
         ],
         "Product discussion done?#RadioButton":[
            "Yes"
         ],
         "CCSL (Super league) discussion done?#RadioButton":[
            "Yes"
         ],
         "Stock taken at the dealer?#RadioButton":[
            "Yes"
         ]
      }
   ]
]

此外,我们能否仅过滤出那些带有'#'的键名?

0 个答案:

没有答案