title: yii2 dynamic submenu from widget Menu
body: <p>all I need to understand is why I always get generated array having 0 index if I declare the value I want
  I want this output</p>
  
  <pre><code>    Array
  (
      [0] =&gt; Array
      (
          [label] =&gt; Prima categoria,
          [url] =&gt; Array
          (
              [0] =&gt; categorie/prima-categoria
          )
      )
  
  [1] =&gt; Array
              (
      [label] =&gt; Seconda
      [url] =&gt; Array
                 (
              [0] =&gt; categorie/seconda
                 )
              [items] =&gt; Array
                    (
                      [label] =&gt; Seconda
                      [url] =&gt; Array
                    (
               [0] =&gt; categorie/seconda
              )
          )
      )
  )
  </code></pre>
  
  <p>but now:</p>
  
  <pre><code>   Array
  (
      [0] =&gt; Array
          (
              [label] =&gt; Prima categoria,
              [url] =&gt; Array
                  (
                      [0] =&gt; categorie/prima-categoria
                  )
          )
      [1] =&gt; Array
          (
              [label] =&gt; Seconda
              [url] =&gt; Array
                  (
                      [0] =&gt; categorie/seconda
                  )
              // this is the problem --- why 0??
              [0] =&gt; Array
                  (
                      [items] =&gt; Array
                          (
                              [label] =&gt; Seconda
                              [url] =&gt; Array
                                  (
                                      [0] =&gt; categorie/seconda
                                  )
  
                          )
                  )
          )
      )
  </code></pre>
  
  <p>the function I am trying to implement</p>
  
  <pre><code>function getItems() {
  $items = [];
  foreach (getLabelName() as $key) {
      $url = str_replace(' ', '-', $key-&gt;name);
      $subMenu = [];
      if (isset($key-&gt;id_sub_cat)) {
          $subMenu['items'] = ['label' =&gt; ucfirst($key-&gt;name), 'url' =&gt; ['category/' . $url . '']];
      }
  
      $items[] = ['label' =&gt; ucfirst($key-&gt;name), 'url' =&gt; ['category/' . $url . ''], $subMenu];
  }
  return $items;
  </code></pre>
  
  <p>}</p>
  
  <p>Hope you understand my explanation. </p>