I'm new at php so my question might seem pretty basic to some of you.
I am trying to parse an xml doc (a list of hotels) using php. The idea is to create a page for each city and then one per hotel.
What I am trying to do is to create some array_unique to get all hotel in which city on the city page.
Here are the codes I am using: Does anyone has a better solution?
$citydata = "";
foreach ($xmlfile->Hotel as $hotel){
$locationname = ($hotel->Location);
$uniquelocations = array_unique($locationname);
$citydata .= "".$uniquelocations."<br />";
}
Cheers,
Em.
Array_Unique Php
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Array_Unique Php
Code: Select all
$locationNames = array();
foreach ($xmlfile->Hotel as $hotel){
$locationNames[] = $hotel->Location;
}
$uniqueLocationNames = array_unique($locationNames);
-
emilie6709
- Forum Newbie
- Posts: 3
- Joined: Thu Dec 18, 2008 10:14 am
Re: Array_Unique Php
Brilliant! Thanks so much!