Find Equal Array php -


i have associate array :

$json_data = array(); $jason_data[]= array ('id'=>'1','brand'=>'chanel','name'=>'red'); $jason_data[]= array ('id'=>'3','brand'=>'lacoste','name'=>'green'); $jason_data[]= array ('id'=>'1','brand'=>'chanel','name'=>'red'); 

$jason_data[0] , $jason_data[2] equal

i want find in $jason_data equal array , echo them

i don't know whats context of , question vague, anyway, hope want achieve. (and variable naming odd). in example index 0 , 2 same, , since multi-dimensional, can flatten them in way using serialize. try this:

$json_data = array(); $json_data[]= array ('id'=>'1','brand'=>'chanel','name'=>'red'); $json_data[]= array ('id'=>'3','brand'=>'lacoste','name'=>'green'); $json_data[]= array ('id'=>'1','brand'=>'chanel','name'=>'red');  $json_data = array_map('serialize', $json_data); $values = array_count_values($json_data);  echo '<pre>'; foreach($values $array => $count) {     if($count > 1) {         $array = unserialize($array);         print_r($array);     } } 

should output/print ones has duplicates:

array (     [id] => 1     [brand] => chanel     [name] => red ) 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -