Unique Variable in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
emilie6709
Forum Newbie
Posts: 3
Joined: Thu Dec 18, 2008 10:14 am

Unique Variable in php

Post by emilie6709 »

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.
Post Reply