php把秒转换为时分秒

function set_time($time){
$status = true;
$str = '';
$i = 0;
$info = array(
    'hour'=>'小时',
    'minute'=>'分钟',
    'second'=>'秒'
);
$arr = array(
    'hour'=>floor($time/3600),
    'minute'=>floor($time%3600/60),
    'second'=>floor($time%3600%60)
);
foreach($arr as $key=>$value){
    $i++;
    if($value != 0 && $status){
        $status = false;
        $str .= $value.$info[$key];
        if($i < 3){
            $status = true;
        }
    }
}
if($str) return $str;else return '0秒';