seadonkey Posted March 12, 2008 Share Posted March 12, 2008 What I am working on is making a guest book to where I write the valuables(name/last/email) to the guest list if it does not exist yet. My problem is with getting the information into the guest book to write. For the sort, instead of using fopen and fgets, use file() to read the whole file into an array, say $GuestBookArray. Then you can sort by saying sort($GuestBookArray); Then use a for loop to loop through the array and print the elements. As a noobie I am trying to figure out how to understand the file function and how to do this. it should be file(filename[, use_include_path]) so for this part would it look like file(guestbook.txt. , "a"[, use_include_path]) (would the include path be the $GuestBookArray? Then the loop part is tossing me for a loop. ??? Any suggestions would be great Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 12, 2008 Share Posted March 12, 2008 file() will not let you write into a file, it is purely for reading. you will have to use fopen/fwrite update: you can use file to read from the guestbook though: <?php foreach(file('guestbook.txt') as $line){ //do stuff to $line } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.