I have found what the problem is
say u have an array with 10 values in it but half of them are duplicates - (so you only actually have 5 unique values) if you then perform array_unique() on the array you will discard the duplicate values.
my question is what is the best way to reset the indexing of the array (the association of the index and the value is not important)?
As you can see from the loop below the new (unique) array will only contain 5 values and as i am using the count() of the array for the loop it will only loop 5 times. As i am using the loop variable $i to step through the array, any values with an index of greater than 5 will be missed.
Does that make sense?
Code: Select all
$arr_unique_saved_tags = array_unique($arr_saved_tags);
$array_size=count($arr_unique_saved_tags);
$related_tags = '<select name="related_tags" SELECTED>Choose a tag';
$related_tags .= '<option value="" selected="selected">Make a Selection</option>';
for($i=0; $i<=$array_size; $i++){
$related_tags .= '<option value="' . $arr_unique_saved_tags[$i] . '">' . $arr_unique_saved_tags[$i] . '</option>';
}
$related_tags .= '</select>';rj