I knew just the very basic stuff in PHP, but I would like to know how to read from a flat file generated by a guestbook. My aim was to show the latest entry of the guestbook on another page of my website, and in order to do this I must extract the bottommost entry from a flat file and extract the information necessary. The content of the flat file is like this:
20011115031709||November 15, 2001 - 03:17 AM||alfredo.palconit||palconit@ulupong.com||Philippines||i like your site. it\'s smple and neat. i wish mine was better than yours, hehehe||http://alfredo.palconit.com
20011118162340||November 18, 2001 - 04:23 PM||vince||starduimpl||Philippines||Comments >>>this is totally great!!!||http://
WIth my limited knowledge, I was able to create this small script that can extract the last entry of the guestbook which is like this:
<?php
// isingit ang dati han na
$fcontents = file ('whiteliter.dat');
echo $fcontents[count($fcontents)-1];
?>
The result is like this:
20011118162340||November 18, 2001 - 04:23 PM||vince||starduimpl||Philippines||Comments >>>this is totally great!!!||http://
It was successful in retrieving the last entry, but it is not yet formatted. My problem right now, is how can I remove the delimiter and put it on different arrays just like in the guestbook. I only wanted to get the (1) comments, (2) name of the signer linking to his/her (3) email from the last entry of the g-book.
(I tried using the string "explode" but i cant figure it out.)
If you wanted to view my personal homepage with the guestbook the url is http://www.kuwentuhan.com/nothingtodo/
Thanks!
Gilbert