This script reads form a file ("shout.txt"), this file stores names of visitors and the messages they left. Somewhat like a mini guestbook.
This is the contents of shout.txt file.
Megahertza||Radeon|+|Megahertza||Newentry|+|
this scripts explodes |+| as every entry and then it explodes each entry by || into name and message, the rest of the script echos out each message into a table. I' still much a noob so any feed back is welcomed.
$file = "shout.txt"; // Contains names and thier messages
$filepointer = fopen($file, "r");
$data = fgets($filepointer, 4096);
$entry = explode("|+|", $data); /* explodes shout in to array, each array contains a name and message */
fclose($filepointer);
$s = count($entry); /* Count total ammount of message in file */
if ($s > 15) {$s = 15;} /* Only show a max of 15 messages */
$entry = array_reverse($entry); /* Reverses array to show newest entries first */
$i = 0;
echo "<table bgcolor='#666666'>";
while ($i < $s) { /* Explodes a max of 15 */
$info = explode("||", $entry[$i]); /* Explodes each array component in to name and message */
echo "<tr><td bgcolor='#333333' width='135'>".$info[0]."</td>"."<td bgcolor='#999999' width='100%'>".$info[1]."</td></tr>";
$i++;
}
echo "</table>";