Read file and modify line by line before echo ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Read file and modify line by line before echo ??

Post by Peuplarchie »

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:

Code: Select all

 
 
<?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!
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Re: Read file and modify line by line before echo ??

Post by Peuplarchie »

I have tried but it don't work.

Thanks !
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Re: Read file and modify line by line before echo ??

Post by Peuplarchie »

I don't know how to make it work that is why I have ask you help !
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Re: Read file and modify line by line before echo ??

Post by Peuplarchie »

I had to use array, thanks !
Post Reply