PHP 闭包函数 function use 用法实例

WBOY
Release: 2016-06-23 13:46:45
Original
1477 people have browsed it

/** * @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));}
Copy after login
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template