nepalipunk
nepalipunk

Reputation: 744

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.

Upvotes: 2

Views: 80

Answers (3)

Adrian Gunawan
Adrian Gunawan

Reputation: 14429

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"]);. 

Upvotes: 1

user978548
user978548

Reputation: 721

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

It's a 3 dimensions array.

Upvotes: 1

sandeep
sandeep

Reputation: 2234

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

Upvotes: 3

Related Questions