Page 1 of 1

if true go to next line

Posted: Thu Nov 08, 2007 12:20 pm
by eon201
Hi,

Im looking for a function that allows me to get to the nest line of a file that is read if something is true eg...

Code: Select all

$fp = fopen($filename, "r"); //Open the server log
        $content = fread($fp, filesize($filename));     // Read the server log   
        $content = explode("\n", $content); // explode into array   
        $content  = array_reverse($content ); // reverse the array

$a = 2;
if ($a <3 'then goto next line of file'){
then do some stuff in here}

else{}
Can anyone help with this please??

Thanks. Eon201

Posted: Thu Nov 08, 2007 5:24 pm
by feyd
file() may be of interest..

so may array_pop() and/or array_shift() depending on how you alter the code.

Posted: Thu Nov 08, 2007 6:27 pm
by Christopher
I don't understand 'go to the next line'? You have the contents of the file in an array, just index into/through the array to the line you want.