title: PHP foreach alternate syntax
body: <p>I am learning PHP from the book "Murach PHP and MySQL 2nd Edition" and I came across this code which I don't fully understand...</p>
  
  <pre><code>&lt;select name="productkey"&gt;
       &lt;?php foreach ($products as $key =&gt; $product):
              $cost = number_format($product['cost'], 2);
              $name = $product['name'];
              $item = $name . ' ($)' . $cost . ')';
       ?&gt; 
       &lt;option value="&lt;?php echo $key; ?&gt;"&gt; &lt;?php echo $item; ?&gt;&lt;/option&gt;
  
       &lt;?php endforeach; ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Why are there instructions after the colon (:) at the start of the foreach loop??</p>
  
  <p>I read that after the colon there should be "?>" and then the instructions to execute and then at end "" to mark the end of the foreach loop...</p>
  
  <p>Please explain this AND IF I WRITE THE LINES STARTING WITH $cost,$name and $item after <code>&lt;?php foreach ($products as $key =&gt; $product): ?&gt;</code> would the code still work???</p>