How to remove duplicate values from an array in PHP

Array
(
    [0] => Huelva
    [1] =>  Huelva
    [2] =>  España
)

I am using array_unique($array); doesn’t work why?

Looks like they’re not the same. I see what looks to be a leading white space in element 1 that isn’t in element 0.

If you are inputting your data into a database that is one good reason to either have a populated dropdown for some of your form inputs or validate them before inputting them.
For instance you could trim the input, change it all to lowercase and then capitalise the first letter of each word. Possibly change the design of your database so the locations are in a separate table.
Of course you may not be getting your array from a database and the above is not of any use :wink:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.