3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '2017-05-01' => [ 'DC' => [ 'IT' => [90, 0], 'DE' => [18, 315, 40, '', 69, 211], 'Other' => [107, 46, '', '', 27, 22] ] ], '2017-05-02' => [ 'DC' => [ 'IT' => [70, 40, 55], 'DE' => ['', 31, 4, '', 9], 'Other' => [1107, 12, 0, 20, 1, 11, 21] ] ], 'fringe case' => [ 'DC' => [ 'IT' => [], 'DE' => ['', '', '', 99], 'Other' => ['', 99] ] ] ]; array_walk( $array, fn(&$dateSet) => array_walk( $dateSet, fn(&$dcSet) => array_walk( $dcSet, function (&$set) { if (!$set) { $set = 0; return; } sort($set); $count = count($set); $mid = intdiv($count, 2); if ($count & 1) { $set = $set[$mid]; return; } $set = ((int)$set[$mid - 1] + (int)$set[$mid]) / 2; } ) ) ); var_export($array);
Output for git.master, git.master_jit
array ( '2017-05-01' => array ( 'DC' => array ( 'IT' => 45, 'DE' => 54.5, 'Other' => 24.5, ), ), '2017-05-02' => array ( 'DC' => array ( 'IT' => 55, 'DE' => 4, 'Other' => 12, ), ), 'fringe case' => array ( 'DC' => array ( 'IT' => 0, 'DE' => 0, 'Other' => 49.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:
46.86 ms | 406 KiB | 5 Q