Home Codeigniter How to remove duplicate values from multidimensional array?

How to remove duplicate values from multidimensional array?

by Shahriar Sagor

Today now in this post i will show you How to remove duplicate values from multidimensional array in php? Sometimes, we may need to remove all duplicates value from the multidimensional array in our PHP project or any framework of php as like laravel, codeigniter, zend etc. So now here, in this example i am going to give you an example of how to get unique values from the multidimensional array on that way duplicates we can be delete.

Here in this example i have a simple multidimensional array also with duplicates values on this array and here i will be perform to get only the unique values from our multidimensional. So It is a possible on core PHP by using array_map() and array_unique(). Here It will helps us to remove all the duplicates values from the multidimensional array.

Remove duplicate Values:
$myArray = Array(
          Array('php','sql'),
          Array('javascript','c'),
          Array('php','sql'),
          Array('c','java')
        );
$myArray = array_map("unserialize", array_unique(array_map("serialize", $myArray)));


print_r($myArray);

Read Also: How to Solve – Installation request for guzzle/guzzle in laravel?

Thanks for read. I hope it help you. For more you can follow us on facebook

close

You may also like