Jump to content

How read Alternative lines from a TXT files


hmvrulz

Recommended Posts

Well, i'd read the lines into an array, set a variable to zero, increment that variable inside a foreach loop and only echo when it's divisible by two:

$file = file('path/to/file.txt');
$i = 0;
foreach($file as $line){
if($i % 2 == 0){
	echo $line.'<br />';
}
$i++;
}

Well, i'd read the lines into an array, set a variable to zero, increment that variable inside a foreach loop and only echo when it's divisible by two:

$file = file('path/to/file.txt');
$i = 0;
foreach($file as $line){
if($i % 2 == 0){
	echo $line.'<br />';
}
$i++;
}

Thanx

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.