Many times, we need to remove double values for many different members in our PHP php framework like laravel, codeigniter, zend etc. Today, In this example I will give you an example of finding different values from many different members thus duplicates will be removed.

In this example I have a simple multidimensional array with double the number of values and I will only get different values from multidimensional. Possible with core PHP array_map() and array_unique(). It helps to remove duplicate values from multiple members.

Example

Array
(
    [0] => Array
    (
        [0] => abc
        [1] => def
    )

    [1] => Array
    (
        [0] => ghi
        [1] => jkl
    )

    [2] => Array
    (
        [0] => mno
        [1] => pql
    )

    [3] => Array
    (
        [0] => abc
        [1] => def
    )

    [4] => Array
    (
        [0] => ghi
        [1] => jkl
    )

    [5] => Array
    (
        [0] => mno
        [1] => pql
    )

)

Remove duplicate Values

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

Output

Remove duplicate values from multidimensional array in PHP