Problem with sort and then output
<p>Im using the PHP below to generate some HTML output:</p>

<pre><code>&lt;?php

$url = "images.xml";
$xmlstr = file_get_contents($url);
$xml = new SimpleXMLElement($xmlstr);  
$images = array();
$ids = array();

foreach ($xml-&gt;image as $image) {

    $images[]['id'] = $image -&gt; id;
    $images[]['link'] =  $image-&gt;href;
    $images[]['src'] = $image-&gt;source;
    $images[]['title'] = $image-&gt;title;
    $images[]['alt'] = $image-&gt;alt;
    $ids[] = $image -&gt; id;
}

array_multisort($ids, SORT_ASC, $images);

foreach ($images as $image){
    echo "&lt;a href='".$image['link']."'&gt;&lt;img src='".$image['src']."' alt='".$image['alt']."' title='".$image['title']."' /&gt;&lt;/a&gt;";
}
?&gt;
</code></pre>

<p>If I change the code here:</p>

<pre><code>foreach ($images as $image){
echo $image['link'];
    echo "Item";
}
</code></pre>

<p>I get the image link 3 times, which is correct because there are 3 records in the XML. But I get 12 copies of the text Item.</p>

<p>Why is this happening?</p>
