PHP: Loop through text file and isolate lines which a specific "starting point"
Posted
by
Mestika
on Stack Overflow
See other posts from Stack Overflow
or by Mestika
Published on 2011-01-14T16:49:08Z
Indexed on
2011/01/14
16:54 UTC
Read the original article
Hit count: 205
Hi everyone,
I’m trying to reduce some editing time within some textfiles where there approximately are 10.000 lines of text, but I only need around 200 or some.
The text file relies on a almost specific pattern but it deviates from time to time but my “focus” in order to select the right line to keep is, that the line always starts with: z3455 and then have a variable afterwards, e.g.: z3455 http://url.com/data1/data1.1/data1.3/ (342kb)
I have an algorithm to capture the URL and its content but now I need some way to loop through the text file, deleting all lines except does that starts with z3455 and then “push” them together so they are listed underneath each other.
I’ve tried different approaches for this in PHP but can’t seem to find a correct function. I can “isolate” a specific line number but when it deviates I can’t use this approach fully.
I hope that someone can help me, either by providing the code or knocking me in the right direction to how I’ll solve this problem.
Thanks in advance
Sincerely
- Mestika
© Stack Overflow or respective owner