title: How can I output specific data from an associative array in PHP with foreach
body: <p>My associative array:</p>
  
  <pre><code>$products = array();
  $products[101] = array(
      "name" =&gt; "Red Shirt",
      "img" =&gt; "img/shirts/shirt-101.jpg",
      "price" =&gt; 18
  );
  $products[102] = array(
      "name" =&gt; "Black Shirt",
      "img" =&gt; "img/shirts/shirt-102.jpg",
      "price" =&gt; 20
  );
  $products[103] = array(
      "name" =&gt; "Blue Shirt",
      "img" =&gt; "img/shirts/shirt-103.jpg",    
      "price" =&gt; 20
  );
  </code></pre>
  
  <p>So lets say I wanted to output the name of ALL products array like so:</p>
  
  <blockquote>
    <p>Red Shirt, Black Shirt, Blue Shirt</p>
  </blockquote>
  
  <p>how can I achieve that with a foreach loop? I have tried to output only a specific key from all arrays at once but I cannot seem to do it without outputting all the keys.</p>
  
  <p>Also lets say I wanted to just output the "price" of a certain array like $products[103] how can I achieve that?</p>
  
  <p>Thank you!</p>