How to display once elements of array ?. For example
var array = ["b","c","c","a","d","e","a","d"]
show => ["a","b","c","d","e"] ?
Any example ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
array_unique()function to remove the duplicates and sort – http://php.net/manual/en/function.array-unique.phpFollowing up with the
array_values()function will remove the gaps in the array index – http://php.net/manual/en/function.array-values.phpIn Javascript/jQuery you can use the
unique()andsort()methodsIf you are sorting numbers in Javascript, you would need to pass a function, as the array is sorted lexicographically be default