title: Laravel - can't get values from multidimensional array with blade
body: <p>I am having trouble looping through a multidimensional array with blade in laravel. I am sending the data from the controller like so: </p>
  
  <pre><code>return View::make('store.categories')
              -&gt;with('brands', $brands);
  </code></pre>
  
  <p>And if I die dump the data:</p>
  
  <pre><code>array (size=2)
    0 =&gt; 
      array (size=2)
        0 =&gt; string 'Fender' (length=6)
        1 =&gt; string '(2)' (length=3)
    1 =&gt; 
      array (size=2)
        0 =&gt; string 'Gibson' (length=6)
        1 =&gt; string '(1)' (length=3)
  </code></pre>
  
  <p>I've tried to use two <code>@foreach</code> loops but I couldn't get it to work: </p>
  
  <pre><code>@foreach($brands as $brand)
    @foreach($brand as $b)
    {{$b}}
    @endforeach
  @endforeach
  </code></pre>
  
  <p>The above will output: <code>Fender (2) Gibson (1)</code>. 
  <hr/>
  I tried to get the 0 value for the <code>$b</code> to output <code>Fender</code> but it just prints the 0 position character for each of the items in the <code>$b</code> array: </p>
  
  <pre><code>@foreach($brands as $brand)
    @foreach($brand as $b)
    {{$b[0]}}
    @endforeach    
  @endforeach
  </code></pre>
  
  <p>The above will output <code>F ( G (</code>. </p>
  
  <hr/> 
  
  <p>In my controller if I do: </p>
  
  <pre><code>foreach ($brands as $b) {
      foreach($b as $key=&gt;$v) {
         dd($v);
      }
  }
  </code></pre>
  
  <p>it will output <code>string 'Fender' (length=6)</code>, which seems like the second loop inside the first <code>@foreach</code> works. Although, when it comes to the blade code mentioned above it doesn't. </p>
  
  <p><em>I'm probably doing something terribly wrong. How can I get the output for the values 0 and 1 for the nested arrays individually? Any help is highly appreciated.</em> </p>
  
  <hr/> 
  
  <p>This is how I create the data in my controller's function: </p>
  
  <pre><code>$products = Product::with('brand')-&gt;whereIn('category_id', $children-&gt;lists('id'));
  $brand_ids = array();
  $brands = array();
  
  foreach ($products-&gt;get() as $p) {
      $brand_ids[] = $p-&gt;brand_id;
  }
  $brand_count = array_count_values($brand_ids); 
  foreach ($brand_count as $key=&gt;$value) {
      $query = Brand::where('id', '=', $key)-&gt;lists('name');
      // dd($query);
      foreach($query as $key=&gt;$name) {
          $array = array(
               $name,
               '('.$value.')'
              );
          $brands[] = $array;
      }
  }
  </code></pre>