Hi,
I am building a drop down menu of cities from an xml file.
Because the xml file contain duplication I used the function in array to make sure I don't echo twice the same value.
This is the code:
Yet when I run it, I still get the same value more than once.Code:<?php $DiurPlus=file_get_contents('http://www.diur-plus.co.il/xml.aspx'); $xmlDiurPlus=simplexml_load_string($DiurPlus); $imagelist=$xmlDiurPlus; echo "<select>"; $cities=array(); foreach ($xmlDiurPlus->propertyList as $propertylist){ if (!in_array($propertylist->city,$cities)){ echo '<option value="'.$propertylist->city.'">'.$propertylist->city.'</option>'; $cities[]=$propertylist->city; } } echo "</select> "; ?>
Where is my mistake?


Reply With Quote

Bookmarks