title: How to fetch values from Nested foreach loop array (fetch Product details category-wise)?
body: <p>I have a long array from which I wish to fetch all the values to show
   them php front-end page. I have two tables in database.  </p>
  
  <ol>
  <li>Category - cat_id, cat_name; </li>
  <li><p>List item product - pro_id, cat_id,
  cat_name,  pro_name, price;</p>
  
  <p>My array is given below:</p>
  
  <pre><code>Array( [0] =&gt; Array (
              [3] =&gt; Array( [cat_id] =&gt; 3
                      [cat_name] =&gt; Mobile Phones
                      [product] =&gt; Array(
                              [26] =&gt; Array(
                                      [pro_id] =&gt; 26
                                      [pro_name] =&gt; iPhone 7
                                      [price] =&gt; 70000
                                  )
                              [25] =&gt; Array(
                                      [id] =&gt; 25
                                      [pro_name] =&gt; iPhone 6
                                      [price] =&gt; 60000
                                  )                           
                          )
                  )
          )
  
      [1] =&gt; Array(
              [5] =&gt; Array([id] =&gt; 5
                      [name] =&gt; Software
                      [product] =&gt; Array(
                              [21] =&gt; Array(
                                      [id] =&gt; 21
                                      [pro_name] =&gt; Lorem Ipsum is simply
                                      [price] =&gt; 5000
                                  )
                              [11] =&gt; Array
                                  (
                                      [id] =&gt; 11
                                      [pro_name] =&gt; Lorem Ipsum is simply
                                      [price] =&gt; 10000
                                  )
                          )
                  )
          )
  [2] =&gt; Array( [4] =&gt; Array([id] =&gt; 4
                      [name] =&gt; Accessories
                      [product] =&gt; Array(
                              [20] =&gt; Array(
                                      [id] =&gt; 20
                                      [pro_name] =&gt; japan
                                      [price] =&gt; 40000
                                  )
                          )
                  )
          )
  </code></pre></li>
  </ol>
  
  <p>I am unable to fetch the values of this array by using this code:</p>
  
  <pre><code>if(!empty($product)){
              foreach($product as $catname){
                echo $catname['cat_name'];
                echo "&lt;br&gt;";
                 foreach($product[] as $detail=&gt; $row {
                      echo $row['product_id'];
                      echo $row['pro_name'];
                      echo $row['price'];         
                 } 
  </code></pre>
  
  <p>Its showing error. But I want output like this:</p>
  
  <pre><code>Mobile Phones
     26
     iPhone 7
     70000
  
     25
     iPhone 6
     60000
  
  
  Software
     21
     Lorem Ipsum is simply
     5000
  
     11
     Lorem Ipsum is simply
     10000
  
  
  Accessories
     20
     japan
     40000
  </code></pre>