Satanas Posted August 2, 2008 Share Posted August 2, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/117835-get-some-lines-on-text-file-until-find-some-word/ Share on other sites More sharing options...
cooldude832 Posted August 2, 2008 Share Posted August 2, 2008 http://us2.php.net/manual/en/function.stristr.php might be useful to you Quote Link to comment https://forums.phpfreaks.com/topic/117835-get-some-lines-on-text-file-until-find-some-word/#findComment-606078 Share on other sites More sharing options...
Satanas Posted August 2, 2008 Author Share Posted August 2, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/117835-get-some-lines-on-text-file-until-find-some-word/#findComment-606130 Share on other sites More sharing options...
LemonInflux Posted August 2, 2008 Share Posted August 2, 2008 May I point you to http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/ ? It's an invaluable resource for me ---------------- Now playing: Linkin Park - By_Myslf (Josh Abraham & Mike Shinoda) via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/117835-get-some-lines-on-text-file-until-find-some-word/#findComment-606134 Share on other sites More sharing options...
Satanas Posted August 2, 2008 Author Share Posted August 2, 2008 Could you give me a clue? ??? Tks. Quote Link to comment https://forums.phpfreaks.com/topic/117835-get-some-lines-on-text-file-until-find-some-word/#findComment-606159 Share on other sites More sharing options...
LemonInflux Posted August 2, 2008 Share Posted August 2, 2008 Try the regex board. I know very little about regex without taking an hour or so, haha ---------------- Now playing: Linkin Park & Jay-Z - Jigga What/Faint via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/117835-get-some-lines-on-text-file-until-find-some-word/#findComment-606161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.