Skip to content

Instantly share code, notes, and snippets.

@vsync
Created May 31, 2013 00:43
Show Gist options
  • Save vsync/5682315 to your computer and use it in GitHub Desktop.
Save vsync/5682315 to your computer and use it in GitHub Desktop.
<?php
$filename = 'leikkikentta.csv'; // viestitiedosto
if(!file_exists($filename)) {
touch($filename);
// echo 'no comments'; voi muuttaa, tai jättää pois kokonaan
}
else {
$handle = fopen($filename, 'r');
while (($data = fgetcsv($handle, 2048, ",")) !== FALSE) { // Luetaan tiedosto arrayhyn.
$rows[] = $data;
}
fclose($handle);
$rows = array_reverse($rows); // Kaannetaan array ympari ja tulostetaan se (uusin nakyy ensin)
foreach($rows as $data) {
?>
<div class="comment">
<span class="msg"><?php echo $data[3]; ?></span>
<a href="mailto:<?php echo $data[1]; ?>"><span class="name"><?php echo $data[0]; ?></span></a><br>
<span class="url"><?php echo $data[2]; ?></span><br>
<span class="timestamp">[ <?php echo $data[4]; ?> ] + [ <?php echo $data[5]; ?> ]</span>
</div>
<?php
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment