简体   繁体   中英

Retrieving values from multi level array

Hi would love some help on how to perform this. Cause so far what I'm doing now is failing. this is the sample output of json turned to array.

        Array
    (
        [0] => Array
            (
                [0] => Array
                    (
                        [value] => lit-PR-00-Preparing-Precise-Polymer-Solutions.html
                    )

            )

        [1] => Array
            (
                [0] => Array
                    (
                        [value] => 90Plus
                    )

            )

        [2] => Array
            (
                [0] => Array
                    (
                        [value] => Particle Size Analyzer
                    )

            )

    )

So far this is what I got so far and It's still not outputting the value I need. Would appreciate some help on what I'm doing wrong thanks.

$decode = json_decode($row['elements'], true);

                echo '<pre>';
                //print_r($decode);
                print_r(array_values($decode));
                echo '</pre>';

                echo ($value['0'][1][value]);
$decode = json_decode($row['elements'], true);

// iterate through array
foreach($decode as $array_row) {
  echo $array_row[0]['value'];
}

// display specific row #2
echo $decode[2][0]['value'];

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