Read Json/Array string in Php

后端 未结 2 585
悲哀的现实
悲哀的现实 2020-12-12 02:06

I have a string which is in valid Json format and it looks like this:

{
    \"message\": \"success\",
    \"result\": {
        \"46620\": {
            \"co         


        
2条回答
  •  失恋的感觉
    2020-12-12 02:30

    In JSON, arrays are designated by brackets ([ and ]) while dictionaries only have braces ({ and }).

    You could access each result object individually by doing $obj['result']['46620']['en_title']. The result object is an associative array (also known as a dictionary) of associative arrays.

    You can also iterate through each object using a foreach loop, as demonstrated in this question

提交回复
热议问题