0

I am getting the duplicate array like this:-

Array ( [0] => Afghanistan [1] => Albania ) Array ( [0] => Afghanistan [1] => Albania ) 

How I remove the this duplicate array... I want output like this..

Array ( [0] => Afghanistan [1] => Albania )

Please help me out. Thanks in advance.

Junaid afzal
  • 109
  • 5
  • 17
  • 1
    Show us what you have tried in order to solve this – Epodax Jan 11 '16 at 12:02
  • As it seems like you are outputting the arrays in a loop, so you first would have to create an array an put them all in there, so you could tell if you have duplicates or not – Rizier123 Jan 11 '16 at 12:03

1 Answers1

0

You can try like below:

$input = array_map("unserialize", array_unique(array_map("serialize", $input)));

For more you can visit this link

Community
  • 1
  • 1
Kausha Mehta
  • 2,828
  • 2
  • 20
  • 31
  • Thanks your solution works. But Now I have to update these values one by one in the table how I do this. I know I have to use foreach loop but I am not getting the results. Thanks. – Junaid afzal Jan 11 '16 at 12:12
  • @Junaidafzal Add the output you currently get and what you want that both in your question..... – Kausha Mehta Jan 11 '16 at 12:16
  • @Junaidafzal And if possible then approve this as a answer and +vote it. And create new one with new query. – Kausha Mehta Jan 11 '16 at 12:16