3v4l.org

run code in 300+ PHP versions simultaneously
<?php $times = ['17:45', '13:12', '09:29', '17:32', '16:49', '14:18']; $counts = array_reduce($times, function($counts, $time) { $hour = (int)substr($time, 0, 2); $moment = in_array($hour, range(9, 12)) ? 'morning' : (in_array($hour, range(13, 16)) ? 'afternoon' : 'evening'); $counts[$moment]++; return $counts; }, ['morning' => 0, 'afternoon' => 0, 'evening' => 0]); echo '<pre>'; var_dump($counts); echo '</pre>';
Output for git.master_jit, git.master, rfc.property-hooks
<pre>array(3) { ["morning"]=> int(1) ["afternoon"]=> int(3) ["evening"]=> int(2) } </pre>

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:
115.17 ms | 405 KiB | 5 Q