3v4l.org

run code in 300+ PHP versions simultaneously
<?php $timeslot = []; $timeslot[] = '07:00-08:00'; $timeslot[] = '07:15-07:30'; $timeslot[] = '07:30-08:30'; $timeslot[] = '10:45-11:45'; $min_time = -1; $max_time = -1; $total_minutes = 0; foreach($timeslot as $slot){ list($start_time,$end_time) = explode("-",$slot); $start_time = explode(":",$start_time); $start_time = intval($start_time[0]) * 60 + intval($start_time[1]); // converting to minutes $end_time = explode(":",$end_time); $end_time = intval($end_time[0]) * 60 + intval($end_time[1]);// converting to minutes if($min_time == -1){// or max time for that matter (just basic initialization of these 2 variables) $min_time = $start_time; $max_time = $end_time; $total_minutes += $max_time - $min_time; }else{ if($start_time >= $max_time) $total_minutes += $end_time - $start_time; else if($start_time < $max_time && $end_time > $max_time) $total_minutes += $end_time - $max_time; $min_time = min($min_time,$start_time); $max_time = max($max_time,$end_time); } } echo intval($total_minutes / 60),":",($total_minutes % 60)," hrs";
Output for git.master, git.master_jit, rfc.property-hooks
2:30 hrs

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