Home >Backend Development >PHP Tutorial >PHP 闭包函数 function use 用法实例

PHP 闭包函数 function use 用法实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:46:451514browse

/** * @param string $hisStart * @param string $hisEnd * @param int    $range * @param string $format * * @return array */function createHisRange($hisStart = '00:00:00', $hisEnd = '23:59:59', $range = 3600, $format = 'H:00:00'){    return array_map(function ($time) use ($format) {        return date($format, $time);    }, range(strtotime($hisStart), strtotime($hisEnd), $range));}/** * @param        $ymdStart * @param bool   $ymdEnd * @param int    $range * @param string $format * * @return array */function createYmdRange($ymdStart, $ymdEnd = true, $range = 86400, $format = 'Y-m-d'){    return array_map(function ($time) use ($format) {        return date($format, $time);    }, range(strtotime($ymdStart), strtotime($ymdEnd), $range));}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn