I have array Array ( [0] => 1,2,3,4,5 [1] => 1,2 [2] => 1,2 )

how to remove duplicate elements and i want to single array like

Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5)

Recommended Answers

All 2 Replies

Well, key 1 and 2 are duplicates, not key 0.
You're not really removing duplicates from the example you have given of what you're wanting, you're changing the values of the array.

It's almost like you want to implode the array with comma delimiter, then explode the array on commas, and then remove all duplicates.
If that is what you're after, that could be done like this

array_unique(explode(",", implode(",", $array)));

Excellent problem is solved,
very thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.