简体   繁体   中英

Php array output confusion

In PHP when I do

var_dump($galleryCategoriesThumb);

Output is

    array(1) {


[0]=>
  array(1) {
    ["Gallery"]=>
    array(3) {
      ["id"]=>
      string(3) "190"
      ["photofile"]=>
      string(6) "50.jpg"
      ["gallery_category_id"]=>
      string(2) "58"
    }
  }
}

When I do

var_dump($galleryCategoriesThumb["photofile"]);

I get NULL output. I tried various other options also. All I want to do is echo ["photofile"]. Please help.

试试$galleryCategoriesThumb[0]['Gallery']["photofile"]

Try var_dump($galleryCategoriesThumb[0]["Gallery"]["photofile"]); .

It's a 3 dimensions array.

It is expected that var_dump($galleryCategoriesThumb["photofile"]) returns NULL because "photofile" key does not exist in $galleryCategoriesThumb.

To access "photofile", you need a 'full path' in the array as posted by others

var_dump($galleryCategoriesThumb[0]["Gallery"]["photofile"]);. 

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