Skip to content

Instantly share code, notes, and snippets.

@paulusm
Last active August 29, 2015 13:57
Show Gist options
  • Save paulusm/9365556 to your computer and use it in GitHub Desktop.
Save paulusm/9365556 to your computer and use it in GitHub Desktop.
<?php
//open the file and decode the JSON into an Array
$contents = utf8_encode(file_get_contents("comments.json"));
$commentrecords = json_decode($contents, true);
//If we have comments, loop trhough them and create HTML list items for each
if($commentrecords){
foreach($commentrecords as $commentrecord){
echo "<li>" .$commentrecord["comment"] ;
echo "<br><strong>" . $commentrecord["name"] . "</strong></li>";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment