Created
October 20, 2015 17:30
-
-
Save tamakiii/ebe7a05c4a40238bf9d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('KEY_ID', 0); | |
define('KEY_DATE', 1); | |
/** | |
* @param array $reports | |
* @param string $start | |
* @param string $end | |
* @return array | |
*/ | |
function timeFilter(array $reports, $start, $end) | |
{ | |
$start = strtotime($start); | |
$end = strtotime($end); | |
return array_filter($reports, function(array $report) use ($start, $end) { | |
$current = strtotime($report[KEY_DATE]) ; | |
return $start <= $current && $current < $end; | |
}); | |
} | |
$filepath = $argv[1]; | |
$csv = array_filter(explode(PHP_EOL, file_get_contents($filepath))); | |
$reports = array_map('str_getcsv', $csv); | |
timeFilter($reports, '2015-01-02', '2015-01-05'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment