我让这段代码处理像'4-5‘和'1-7’这样的字符串
$times = explode("-", $time);
$thpw += ($times[1]- $times[0]);问题是当有这样的多个时间格式时。
1-2, 5-6
or
8-12, 1-2, 4-5, 6-7我该如何利用它来捕捉时间呢?
发布于 2014-05-09 08:42:02
也要用爆炸的方法,
$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演示。
https://stackoverflow.com/questions/23560097
复制相似问题