Page 1 of 1

how do you print every other line of a text file

Posted: Sun Dec 20, 2009 10:57 pm
by nevets04
I need a code that prints every other line of a text file.
I.E
a text file contains:
hello
0
there
0
I just want
hello
there
to be displayed

Re: how do you print every other line of a text file

Posted: Mon Dec 21, 2009 3:52 am
by MichaelR

Code: Select all

 
  $file = file_get_contents('index.php');
 
  $file = str_replace("\n0", "\n", $file);
 
  echo $file;