Apr 1 at 8:13pm, Merlin wrote: > I am trying to get continent and country info out of an xml file. There > is a continent element to each country element. Now I do have an array > with the continent info and one with the country info. The goal is to be > able to output all countries sorted after continents. > > $results[]->countryContinent > $results[]->countryName
First, although this does work, I don't know if it's what you want to do. You'll end up with a structure like this: Array ( [0] => stdClass Object ( [countryContinent] => North America ) [1] => stdClass Object ( [countryName] => Canada ) ) Not very useful, as you've found. > I tryed to group those values, to do array searches and more, but somehow > it looks like that there must be a way more easy way to do this. I think this is along the lines of what you want to do: $continent = 'North America'; $landmass[$continent][] = 'Canada'; $landmass[$continent][] = 'United States'; $landmass[$continent][] = 'Mexico'; $continent = 'Asia'; $landmass[$continent][] = 'Japan'; $landmass[$continent][] = 'China'; $landmass[$continent][] = 'Korea'; // sort continents then countries ksort($landmass); // use ksort() to sort by key foreach($landmass as $conti => $cntry) { sort($landmass[$conti]); } print_r($landmass); There's your array, just loop over it as you like, to do your output. If you're reading an XML file, you might look into PEAR, which has packages for parsing and building data structures of XML data. -- Kelly Hallman // Ultrafancy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php