3v4l.org

run code in 300+ PHP versions simultaneously
<?php $multidimensionArray = [ "A2" => [ 0 => "A1", 1 => "A2", 2 => "A3", ], "A1" => [ 0 => "A1", 1 => "A6", 2 => "A5", 3 => "A2", ], "A6" => [ 0 => "A3", ], "A3" => [ 0 => "A3", 1 => "A2", ], "A5" => [ 0 => "A4" ], "A4" => [ 0 => "A4", 1 => "A3", ] ]; $singeArray = [ "A1" => 675.58333333333, "A2" => 1786.75, "A3" => 2897.9166666667, "A4" => 4009.0833333333, "A5" => 5120.25, "A6" => 6231.4166666667, ]; $results = []; foreach ($multidimensionArray as $key => $valueArr) { ## filter out all values of interest from $singleArray $filteredValues = array_filter($singeArray, function ($value, $identifier) use ($valueArr) { return in_array($identifier, $valueArr); }, ARRAY_FILTER_USE_BOTH); ## Here we get the average $results[$key] = array_sum($filteredValues) / count($filteredValues); } print_r($results);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [A2] => 1786.75 [A1] => 3453.5 [A6] => 2897.9166666667 [A3] => 2342.3333333334 [A5] => 4009.0833333333 [A4] => 3453.5 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
127.5 ms | 401 KiB | 8 Q