title: PHP: How can I print multi-dimensional array elements using foreach?
body: <pre><code>$shop = array( 
                  array("Rose", 1.25 , 15),
                  array("Daisy", 0.75 , 25),
                  array("Orchid", 1.15 , 7)
              );
  
  
      for($i = 0; $i &lt;= count($shop); $i++){
          foreach($shop[$i] as $key =&gt; $val)
              echo $key . ' = ' . $val . '&lt;br&gt;';
      }
  </code></pre>
  
  <p>So this is the output I'm getting:</p>
  
  <p>0 = Rose</p>
  
  <p>1 = 1.25</p>
  
  <p>2 = 15</p>
  
  <p>0 = Daisy</p>
  
  <p>1 = 0.75</p>
  
  <p>2 = 25</p>
  
  <p>0 = Orchid</p>
  
  <p>1 = 1.15</p>
  
  <p>2 = 7</p>
  
  <p>============================================</p>
  
  <p>But then I get an error:</p>
  
  <p><strong>Warning</strong>: Invalid argument supplied for foreach()</p>
  
  <p>What I want to know is how to correct this, and if there's a more efficient way to write what I'm trying to output?</p>
  
  <p>Thanks guys.</p>