Skip to content

Instantly share code, notes, and snippets.

@chernjie
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chernjie/c2829e7ee24c2ba0411c to your computer and use it in GitHub Desktop.
Save chernjie/c2829e7ee24c2ba0411c to your computer and use it in GitHub Desktop.
<?php
$handle = fopen($argv[1], 'r');
$handle || exit('no readable file');
$handles = array();
while (($line = fgets($handle)) !== false)
{
if (preg_match('/^201.-..-../', $line, $match))
{
$date = str_replace('-', '', $match[0]);
empty($handles[$date]) && $handles[$date] = fopen($argv[1] . '-' . $date, 'a');
}
fwrite($handles[$date], $line);
}
@chernjie
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment