Problems after reversing a guestbook

From: Date: Sat, 28 Apr 2001 23:03:15 +0000
Subject: Problems after reversing a guestbook
Groups: php.general 
Request: Send a blank email to php-general+get-50774@lists.php.net to get a copy of this message
Hey there! This is my absolutely first time posting in a newsgroup, so be nice please ; ) I've written a guestbook, and in an attempt to get the newest entries first I reversed the guestbook-txt-file. Like so: $tabell = file( "gjestebok.txt" ); $revtab = array_reverse( $tabell ); $antall = count( $revtab ); $i = 0; if( !( $fil = fopen( "guestbook.txt", "r+" ) ) ) die(); while( $i < $antall ) { fwrite( $fil, "$revtab[$i]" ); $i++; } fclose( $fil ); Now the problem: If I post a message with a line of text, a newline (as in hitting the return-key), some more text and newlines, these newline-separated text-lines show before the posting itself after reversing because they are independent elements in the array..... How can I fix this???? Mogens

« previous php.general (#50774) next »