3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 2 => 5, 4 => 1, 8 => 3, 0 => 17, 9 => 2, 11 => 67 ]; $ranges = ['1-5', '6-10', '1000-5000']; var_export( array_reduce( $ranges, fn($result, $range) => $result + [$range => array_sum(array_intersect_key($array, array_flip(range(...sscanf($range, '%d-%d')))))], [] ) );
Output for git.master, git.master_jit
array ( '1-5' => 6, '6-10' => 5, '1000-5000' => 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:
55.36 ms | 862 KiB | 4 Q