php - Unique values of the array with four fields -


i've array this:

array(     0 => array(1, 2, 3, 4),     1 => array(1, 3, 2, 4),     2 => array(1, 2, 4, 3),     3 => array(1, 2, 5, 6) ) 

i have remove records repeated. need have array:

array(     0 => array(1, 2, 3, 4),     3 => array(1, 2, 5, 6) ) 

the script in php.

who can help? :)

this should work you:

just go through each sub array array_map() , sort() arrays. return them implode()'ed. created array can use array_unique() , explode() values again.

<?php      $result = array_map(function($v){         return explode(",", $v);     }, array_unique(array_map(function($v){             sort($v);             return implode(",", $v);         }, $arr)));      print_r($result);  ?> 

output:

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

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -