Page 1 of 1

Read lines separated by semicolon

Posted: Tue Jul 28, 2009 11:40 pm
by lordrt
Hi all
I have a text file whose sentences/texts are delimited by semicolons to indicate end of the current line, example

this is line 1;
this is line 2;
.
.
.

How can I write a php code to read the 1st line, assign to a variable, do some processing, then clear variable and read line 2 and so on?

Re: Read lines separated by semicolon

Posted: Wed Jul 29, 2009 12:25 am
by requinix
file can return an array of all the lines in the file. explode can split lines apart.

Try some combination of those two with a bit of foreach mixed in.

Re: Read lines separated by semicolon

Posted: Wed Jul 29, 2009 12:55 am
by lordrt
thank you tasairis will try it out