Read lines separated by semicolon

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
lordrt
Forum Commoner
Posts: 34
Joined: Sun Jul 19, 2009 11:44 pm

Read lines separated by semicolon

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Read lines separated by semicolon

Post 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.
lordrt
Forum Commoner
Posts: 34
Joined: Sun Jul 19, 2009 11:44 pm

Re: Read lines separated by semicolon

Post by lordrt »

thank you tasairis will try it out
Post Reply