Accessing associative arrays in PHP

前端 未结 2 1418
不思量自难忘°
不思量自难忘° 2020-12-17 19:36

I want to access the index \'memo\' in the associative array in PHP below

$variables[\"thelistitems\"];
print_r($variables[\"thelistitems\"]);
2条回答
  •  隐瞒了意图╮
    2020-12-17 20:12

    What you essentially have is an array of associative arrays. So to access the first memo, it's

     $variables["thelistitems"][0]["memo"]
    

    To access each memo, you'd do something like this

    foreach($variables["thelistitems"] as $listitem) {
        $memo = $listitem["memo"];
    }
    

提交回复
热议问题