3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 'water' => [0, 1, 2, 3, 4, 5], 'apple' => [1, 5, 3, 4, 0, 0], 'beer' => [0, 0, 0, 0, 0, 0] ]; $arrWeight = array_map(function($value) { return is_array($value) ? array_sum($value) : 0; }, $arr); arsort($arrWeight); $arrAllowedKeys = array_slice($arrWeight, 0, 2, true); $arr = array_intersect_key($arr, $arrAllowedKeys); var_export($arr);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'water' => array ( 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, ), 'apple' => array ( 0 => 1, 1 => 5, 2 => 3, 3 => 4, 4 => 0, 5 => 0, ), )

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:
129.58 ms | 406 KiB | 5 Q