Skip to content

Instantly share code, notes, and snippets.

@sebmih
Created November 21, 2013 07:58
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 sebmih/7577579 to your computer and use it in GitHub Desktop.
Save sebmih/7577579 to your computer and use it in GitHub Desktop.
A script that should decode JSON events.
<?php
$handle = @fopen('./tmp/dump.log', "r");
if ($handle)
{
// read till the end of the file
while (!feof($handle))
{
// read a line from the file
$line = fgets($handle, 4096);
// decode the json -> assoc. array
$decoded_line = json_decode($line, true);
?>
<p><strong>Recipient: <?php echo $decoded_line['email'];?></strong></p>
<p>Date: <?php echo date('d M Y H:i:s A e', $decoded_line['timestamp']);?> </p>
<p>Event: <?php echo $decoded_line['event'];?></p>
<?php
}
// close the file
fclose($handle);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment