Jump to content

Get some lines on text file until find some word


Satanas

Recommended Posts

Hi there!

 

I'm learning very much reading some lines in this forum... you're awsome!

I've a little question that is making me crazy...

 

I want to read some lines from a file until it founds the word "</pre>" for that.. I'm reading the first 6 characters of each line.

 

I have this peace of code here:

$var = file('my_file.txt');

 

$line_number = 0;

foreach( $var as $line )

{

$text = substr($var[$line_number], 0, 6); 

        if ($line_number > 14)                           

        echo "<br>" . $var[$line_number];   

        $line_number++;

 

}

 

Any help please?

 

Tks!

OK... I've done it...

Know I've another question...

 

Wich one of the lines I've read has some latitude and longitude coordinates...

How can I read them with a RegEx ? I put in bold what I want to get...

 

Here is the format of the line:

LPPT 0 0 N38°46'27.00" W009°08'03.00" LISBOA

 

Tks!

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.