3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array( 0 => array('value' => 1000, 'name' => 'AA1'), 1 => array('value' => 2000, 'name' => 'AA2'), 2 => array('value' => 3000, 'name' => 'AA3'), 3 => array('value' => 4000, 'name' => 'AA4'), ); $b = array( 0 => array('value' => 1000, 'name' => 'BB1'), 1 => array('value' => 3000, 'name' => 'BB2'), 2 => array('value' => 1700, 'name' => 'BB3'), 3 => array('value' => 1200, 'name' => 'BB4'), ); $c = array( 0 => array('value' => 3000, 'name' => 'CC1'), 1 => array('value' => 4000, 'name' => 'CC2'), 2 => array('value' => 4300, 'name' => 'CC3'), 3 => array('value' => 5000, 'name' => 'CC4'), ); $array = array('a' => $a, 'b' => $b, 'c' =>$c); foreach($array as $letter => $subArray){ foreach($subArray as $key => $values){ $newArray[$letter.$key] = $values['value']; } } $uniques = array_unique($newArray); //getting the non-repeated values $repeated = array_diff_assoc($newArray, $uniques); // stripping them out $final = array_unique($repeated); //cleaning the repeated values to just 1 of each print_r($final);
Output for 4.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [b0] => 1000 [b1] => 3000 [c1] => 4000 )