Created
March 22, 2010 02:46
-
-
Save unlobito/339753 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 | |
$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