Archive

Posts Tagged ‘array’

PHP Remove Duplicate Array Values From Multidimentional Array

August 27, 2012 Leave a comment

    PHP Remove Duplicate Array Values From Multidimentional Array

$inputArray =

Array
(
[0] => Array
(
[0] => 1
[1] => 3
[2] => 6
)

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

[2] => Array
(
[0] => 1
[1] => 3
[2] => 6
)

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

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

)

$input = array_map(“unserialize”, array_unique(array_map(“serialize”, $inputArray)));

/******** Output *************/

Array
(
[0] => Array
(
[0] => 1
[1] => 3
[2] => 6
)

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

)

/*********************** end make unique array *********************/

Advertisements
Categories: PHP Tags: ,