3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a1 = Array ( 0 => (object) array ( 'time' => '03:00 PM - 04:30 PM', 'booked' => 3, ), 1 => (object ) array ( 'time' => '05:00 PM - 06:30 PM', 'booked' => 2 ) ); $a2 = Array ( '0' => (Object) array ( 'time' => '03:00 PM - 04:30 PM', 'booked' => 3 ), '1' => (Object) array ( 'time' => '07:00 PM - 08:30 PM', 'booked' => 1 ) ); $a3 = array_merge($a1,$a2); $r = []; $keys = ['booked','booked_slotes']; foreach($a3 as $v){ array_key_exists($v->time, $r) ? ($r[$v->time]->booked += $v->booked) : ($r[$v->time] = $v); } print_r(array_values($r));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => stdClass Object ( [time] => 03:00 PM - 04:30 PM [booked] => 6 ) [1] => stdClass Object ( [time] => 05:00 PM - 06:30 PM [booked] => 2 ) [2] => stdClass Object ( [time] => 07:00 PM - 08:30 PM [booked] => 1 ) )

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