Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 每半小时生成一个持续时间为的数组_Php - Fatal编程技术网

Php 每半小时生成一个持续时间为的数组

Php 每半小时生成一个持续时间为的数组,php,Php,我想做一个函数,给我一个时间范围数组,如下所示: // passing FROM, TO ( times to the function ) function time( '11:00', '13:00' ) { } // i want to get it like the following [ 0 => '11:00', 1 => '11:30', '2' => '12:00', 3 => '12:30', 4 => '01:00' and so on

我想做一个函数,给我一个时间范围数组,如下所示:

// passing FROM, TO ( times to the function ) 
function time( '11:00', '13:00' ) {

}


// i want to get it like the following 
[ 0 => '11:00', 1 => '11:30', '2' => '12:00', 3 => '12:30', 4 => '01:00' and so on .... ]
我该怎么做

$hourRange = range(strtotime('00:00'), strtotime('23:50'), 10 * 60);

foreach($hourRange as $time){
    $date = date("H:i",$time);
    echo $date . "\n";
}

这里已经回答了: