Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unlobito/339753 to your computer and use it in GitHub Desktop.
Save unlobito/339753 to your computer and use it in GitHub Desktop.
<?php
$audit = file_get_contents('audit.txt');
$audit = split("\n", $audit);
$data = Array();
for ($i=0; $i!=count($audit); $i++) {
$line = $audit[$i];
$datatype = substr($line, 0, 1);
switch ($datatype) {
case '-':
$day = substr($line, 3, 10);
$repPlus = str_replace(' ', '', substr($line, 19, 3));
if (isset($_GET['debug'])) {
echo 'Found day '.$day.' on line '.$i.' (rep +'.$repPlus.')<br />';
}
$data[] = Array('date' => $day, 'rep' => $repPlus);
break;
case ' ':
if (isset($_GET['debug'])) {
echo 'Skipped day detail on line '.$i.'<br />';
}
break;
case '*':
if (isset($_GET['debug'])) {
echo $i.': '.substr($line, 2).'<br />';
}
break;
default:
if (isset($_GET['debug'])) {
echo 'Skipped unknown on line '.$i.'<br />';
}
break;
}
}
if (isset($_GET['debug'])) {
echo '<hr /><b>JSON code follows</b><br /><code>';
}
echo json_encode($data);
if (isset($_GET['debug'])) {
echo '</code>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment