title: How to use foreach with PHP & XML (simplexml)
body: <p>Anyone that knows PHP and XML out there? Then please have a look!</p>
  
  <p><strong>This is my PHP code:</strong></p>
  
  <pre><code>&lt;? $xml = simplexml_load_file("movies.xml");
  foreach ($xml-&gt;movie as $movie){ ?&gt;
  
  &lt;h2&gt;&lt;? echo $movie-&gt;title ?&gt;&lt;/h2&gt;
  &lt;p&gt;Year: &lt;? echo $movie-&gt;year ?&gt;&lt;/p&gt;
  &lt;p&gt;Categori: &lt;? echo $movie-&gt;regions-&gt;region-&gt;categories-&gt;categorie ?&gt;&lt;/p&gt;
  &lt;p&gt;Country: &lt;? echo $movie-&gt;countries-&gt;country ?&gt;&lt;/p&gt;
  
  &lt;? } ?&gt;
  </code></pre>
  
  <p>This is mys XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;movies&gt;
   &lt;movie&gt;
    &lt;title&gt;A movie name&lt;/title&gt;
    &lt;year&gt;2010&lt;/year&gt;
       &lt;regions&gt;
     &lt;region&gt;
      &lt;categories&gt;
        &lt;categorie id="3"&gt;Animation&lt;/categorie&gt;
        &lt;categorie id="5"&gt;Comedy&lt;/categorie&gt;
        &lt;categorie id="9"&gt;Family&lt;/categorie&gt;
       &lt;/categories&gt;
      &lt;countries&gt;
       &lt;country id="123"&gt;USA&lt;/country&gt;
      &lt;/countries&gt;
     &lt;/region&gt;
    &lt;/regions&gt;
   &lt;/movie&gt;
   &lt;movie&gt;
    &lt;title&gt;Little Fockers&lt;/title&gt;
    &lt;year&gt;2010&lt;/year&gt;
       &lt;regions&gt;
     &lt;region&gt;
      &lt;categories&gt;
       &lt;categorie id="5"&gt;Comedy&lt;/categorie&gt;
               &lt;/categories&gt;
          &lt;countries&gt;
           &lt;country id="123"&gt;USA&lt;/country&gt;
      &lt;/countries&gt;
     &lt;/region&gt;
    &lt;/regions&gt;
   &lt;/movie&gt;
  &lt;/movies&gt;
  </code></pre>
  
  <p>The outcome of the code above is:</p>
  
  <pre><code>&lt;h2&gt;A movie name&lt;/h2&gt;
  &lt;p&gt;Year: 2010&lt;/p&gt;
  &lt;p&gt;Category: Animation&lt;/p&gt;
  &lt;p&gt;Country: USA&lt;/p&gt;
  
  &lt;h2&gt;Little Fockers&lt;/h2&gt;
  &lt;p&gt;Year: 2010&lt;/p&gt;
  &lt;p&gt;Category: Comedy&lt;/p&gt;
  &lt;p&gt;Country: USA&lt;/p&gt;
  </code></pre>
  
  <p>I want it to be like this (see category on the first movie):</p>
  
  <pre><code>&lt;h2&gt;A movie name&lt;/h2&gt;
  &lt;p&gt;Year: 2010&lt;/p&gt;
  &lt;p&gt;Category: Animation, Comedy, Family&lt;/p&gt;
  &lt;p&gt;Country: USA&lt;/p&gt;
  
  &lt;h2&gt;Little Fockers&lt;/h2&gt;
  &lt;p&gt;Year: 2010&lt;/p&gt;
  &lt;p&gt;Category: Comedy&lt;/p&gt;
  &lt;p&gt;Country: USA&lt;/p&gt;
  </code></pre>
  
  <p>Note: Also I wonder how to get the comma between the words, but without a comma on the last word...</p>