Unable to access nested array in php -


I have an array like them, I would like to use this kind of sub category array

  currency ($ $ dollar as parent_category) {$ ndata = $ parent_category ['subcategory']; Where $ data is your main array  print_r ($ data)  this issue 

P> When I used this array I got an error undefined index: subcategory

help me ...

  Array ([1] = & gt; array ([name] = & gt; Indian culture [subcategory] => array ([0] => array ([name] => Indain culture 1 [articleId] ] = & Gt; 10) [1] = & gt; array ([name] => culture-1 [articleId] => 22))) [5] => array ([name] = & Gt; ABC culture)  

)

As you are seeing, Here:

  [5] = & gt; Array ([name] => ABC culture) Your array does not have an element with the "sub-category" index, so just check that the index is present by invocation:  
  ... if (isset ($ parent_category ['subcategory'])) {...  

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -