Hi I am new this forum and looking for some much appreciated help with something that has me stumped. I have extracted regions from image names in a directory. example: 'edinburgh_castle_(Edinburgh).jpg' (Extracted Edinburgh from in-between the brackets) So I have a list of Regions, extracted from all the various image names in the directory which I want to populate into a dynamic drop down menu for filtering purposes. Here's my issue... I want there to be only one 'Edinburgh' option appearing in my drop down menu. I don't want duplicates.
Here is my code so far.
php: [select]
$filterByArray2 = array ($truncFilter); $filterByArray = array_unique($filterByArray2, SORT_REGULAR); // sort($filterByArray); echo '<pre>'; var_dump($filterByArray); echo '</pre>';
Produces Result... array(1) {[0]=>string( 7 ) "Glasgow"} array(1) {[0]=>string( 8 ) "Edinburgh"} array(1) {[0]=>string( 8 ) "Edinburgh"} array(1) {[0]=>string( 8 ) "Edinburgh"} A for each loop... foreach ($filterByArray as $key => $value) {echo "$key $value,";} prints out... 0 Glasgow,0 Edinburgh,0 Edinburgh,0 Edinburgh, Can anyone, better than myself, tell me how to return 'Glasgow,Edinburgh' with no duplicates. I'm not sure how to do it when all the $keys are 0? Many thanks in advance.