i got this code working on a string like '4-5' and '1-7'
$times = explode("-", $time);
$thpw += ($times[1]- $times[0]);
the problem is when there are multiple time formats like this..
1-2, 5-6
or
8-12, 1-2, 4-5, 6-7
how should I capture the time using that?
Use explode for that too,
$times = explode(",","8-12, 1-2, 4-5, 6-7");
$thpw = 0;
foreach($times as $time){
$time_arr = explode("-", $time);
$thpw += ($time_arr[1]- $time_arr[0]);
}
echo $thpw; // 7
DEMO.