不需要
explode任何东西:
$str_time = "23:12:95";$str_time = preg_replace("/^([d]{1,2}):([d]{2})$/", "00:$1:$2", $str_time);sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);$time_seconds = $hours * 3600 + $minutes * 60 + $seconds;而且,如果您不想使用正则表达式:
$str_time = "2:50";sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);$time_seconds = isset($hours) ? $hours * 3600 + $minutes * 60 + $seconds : $minutes * 60 + $seconds;



