3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $intersecting_arrays = Array ( 0 => Array ( 'one' => 10, 'two' => 20, 'three' => 50, 'four' => 80, 'five' => 100 ), 1 => Array ( 'three' => 20, 'five' => 20, 'six' => 100, 'seven' => 10 ), 2 => Array ( 'one' => 30, 'three' => 30, 'five' => 10, 'eight' => 10 ) ); $temp = $intersecting_arrays[0]; for($i = 1; $i < count($intersecting_arrays); $i++) { $temp = array_intersect_key($temp, $intersecting_arrays[$i]); } $result = Array(); foreach(array_keys($temp) as $key => $val) { $value = 0; foreach($intersecting_arrays as $val1) { $value+= $val1[$val]; } $result[$key] = $value / count($intersecting_arrays); } print_r($temp); print_r($result);
based on lFUv4
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.2.6
Array ( [three] => 50 [five] => 100 ) Array ( [0] => 33.333333333333 [1] => 43.333333333333 )