steviecee
01-06-2007, 10:22 AM
hi, I'm populating a drop down select box with values from an XML file. I would like it to only populate with unique values, but with the code I have at the moment it only displays the first value, can anyone spot the problem?
$i = 0;
foreach ($entries as $entry) {
$arr[$i++] = $entry->nodeValue;
}
sort($arr);
$last_value = -1;
for ($j = 0; $j < $i; $j++) {
if ($arr[j] != $last_value) {
echo "<option value = '{$arr[$j]}'>{$arr[$j]}</option>";
$last_value = $arr[j];
}
}
cheers
Steve
$i = 0;
foreach ($entries as $entry) {
$arr[$i++] = $entry->nodeValue;
}
sort($arr);
$last_value = -1;
for ($j = 0; $j < $i; $j++) {
if ($arr[j] != $last_value) {
echo "<option value = '{$arr[$j]}'>{$arr[$j]}</option>";
$last_value = $arr[j];
}
}
cheers
Steve