Jump to content

Read 2 lines at a time from a .txt file.


lynxus

Recommended Posts

Hi Guys,

How can i read 2 lines at a time from a txt file.

 

I have a txt file with a bunch of values

ie:

var1 = line1

var2 = line 2

repeat

var1 = line3

var2 = line 4

 

Etc

 

the code i have goes through each line.

What i want is it to read 2 lines, put them into 2 vars for me to use, then repeat doing the same for the next 2 lines then 2 more etc etc until it reaches the end.

 

 

Any ideas?

 

 

<?

// Get VRFS from txt file ( should be DB )

// VRFname

// VRFrd

 

$lines = file('vrfs.txt');

foreach ($lines as $line) {

Echo $line;

 

 

}

 

?>

 

Link to comment
https://forums.phpfreaks.com/topic/185585-read-2-lines-at-a-time-from-a-txt-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.