Peuplarchie Posted November 16, 2009 Share Posted November 16, 2009 Good day to you all, I'm working on a script wich permit me to read a file line by line and echo it. Here is my code now: <?php $console = $_GET["console"]; $name = $_GET["name"]; $file = fopen("info_gen.txt", "r") or exit("Unable to open file!"); //Output a line of the file until the end is reached while(!feof($file)) { echo fgets($file). "<br />"; } fclose($file); ?> My problem is I need to be able to add or edit each and every line seperatly and differently before echo everyting. How can I do so ? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/181693-read-file-and-modify-line-by-line-before-echo/ Share on other sites More sharing options...
forumforme123 Posted December 9, 2009 Share Posted December 9, 2009 You can try to use the explode() function to put every lines in an array. and then loop the array to make the edit. Then write it back to the file. Quote Link to comment https://forums.phpfreaks.com/topic/181693-read-file-and-modify-line-by-line-before-echo/#findComment-973912 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.