3v4l.org

run code in 300+ PHP versions simultaneously
<?php $multi = [ "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", ] ]; $single = [ "A1" => 675.58333333333, "A2" => 1786.75, "A3" => 2897.9166666667, "A4" => 4009.0833333333, "A5" => 5120.25, "A6" => 6231.4166666667, ]; $result = []; foreach ($multi as $key => $row) { $values = array_intersect_key($single, array_flip($row)); $result[$key] = array_sum($values) / count($values); } var_export($result);
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
array ( 'A2' => 1786.75000000001, 'A1' => 3453.5000000000073, 'A6' => 2897.9166666667, 'A3' => 2342.3333333333503, 'A5' => 4009.0833333333, 'A4' => 3453.5, )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
103.43 ms | 407 KiB | 5 Q