简体   繁体   中英

Can't extract data from the result of json_decode php

This is the result of json_decode&echo I recieve, but I cant build a list/table of it. Everything I've found on the topic so far didnt work out for me, maybe its because of complicated nesting. I would apprecieate any help, just point me in the right direction, no need to make all the work for me. Thanks in advance!

Array
(
    [1001] => Array
        (
            [Element] => Array
                (
                    [id] => 1001
                    [name] => Element 1
                )

        )

    [1002] => Array
        (
            [Element] => Array
                (
                    [id] => 1002
                    [name] => Element 2
                )

        )

    [1003] => Array
        (
            [Element] => Array
                (
                    [id] => 1003
                    [name] => Element 3
                )

        )
)

Try foreach

 foreach ( $your_json_array as $key=>$value){
       foreach($value as $ele=>$elearray){
            echo $elearray['id'];
            echo $elearray['name']; 
      }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM