guestbook/fetch-json.php

19 lines
407 B
PHP

<?php
$data = json_decode(file_get_contents('test.json'), true);
echo "<div>";
foreach($data as $post) {
echo '<section class="guestbookpost">';
echo "<h4>";
echo $post["name"] . "<br>";
echo "</h4>";
echo '<h4 class="date">';
echo $post["date"] . "<br>";
echo "</h4>";
echo "<p>";
echo $post["message"] . "<br>";
echo "</p>";
echo "</section>";
}
echo "</div>";
?>