php - yii2 dynamic submenu from widget Menu -


I need to understand why I'm always indexing 0 index if I declare value that I get this output Array ([0] = & gt; array ([label] = gt; prime categoria, [url] = & gt; array ([0] => classification / primary-classification) [1] = & Array ([label] = & gt; Array ([label] = & gt; Array ([0] = & gt; classification / sec) [item] = & gt; Array ([label] = & gt; Url]] = & gt; array ([0] => classification / sec)))

but now:

  Rare ([0] = & gt; Array ([label] = gt; Prima Sategoria, [url] = & gt; Array ([0] => classification / primary category)) [1] = & gt; Array ([label] = & gt; second [url] => array ([0] => classification / sec) // This is the problem --- why 0 ?? [0] = & gt; array Array ([0] => categorization / sec)))  
< P> Function I is trying to implement

  function getItems () {$ items = []; Forex Currency (as getLabelName () $ Key) {$ url = str_replace ('', '-', $ key->;); $ SubMenu = []; If (isset ($ key-> id_sub_cat)) {$ subMenu ['items'] = ['label' = & gt; Ucfirst ($ key->), 'url' = & gt; ['category/' . $ Url '']]; } $ Item [] = ['label' = & gt; Ucfirst ($ key->), 'url' = & gt; ['category/' . $ Url ''], $ SubMenu]; } Return $ item;  

}

Hope you understand my interpretation.

For this reason:

  $ items [] = [' Label '= & gt; Ucfirst ($ key->), 'url' = & gt; ['category/' . $ Url ''], $ SubMenu];  

What should you do

  function getItems () {$ items = []; Forex Currency (as getLabelName () $ Key) {$ url = str_replace ('', '-', $ key->;); $ SubMenu = []; If (isset ($ key-> id_sub_cat)) {$ subMenu [] = ['label' = & gt; Ucfirst ($ key->), 'url' = & gt; ['category/' . $ Url '']]; } $ Item [] = ['label' = & gt; Ucfirst ($ key->), 'url' = & gt; ['category/' . $ Url ''], 'item' = & gt; $ Submenu]; } Return $ item; }  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -