Accessing associative arrays in PHP

前端 未结 2 1419
不思量自难忘°
不思量自难忘° 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"];
    }
    
    0 讨论(0)
  • 2020-12-17 20:32

    Do you want this ?

    $variables["thelistitems"][0]['memo']
    
    0 讨论(0)
提交回复
热议问题