Hi
An ideea is to use the file(‘file.txt’) function (see on php.net ). It creates an array with the rows from a file.
Then you can traverse the array (with for() ), and apply some instructions, like preg_match() to store in another array the lines you want.
My thoughts exactly Although I wasn’t sure on whether or not the start would be uniform, so kinda just made it arbitrary. It’s a strange format of data file, I must say.
Out of interest, why did you opt for $extract being an integer rather than a boolean?
If start pattern could have different formats then we can use preg_match() as you did to check for various pattern that can be used.
Although the example can use boolean, if $extract is true then extract the line and reset it back to false. However, if the match requirement is changed, say you want to extract all the lines till end pattern is found, which might expand more than one lines, then we need to set it to some number telling us whether or not the line is to be exacted. There might be some other conditions where $extract need to assign a different value to take on an appropriated action. Hope this make sense.