I have a need of scraping information from text files that comes in format like so:
I know how to get the delimiter from between the quotes. using that delimiter i have to go through each section, and set the name in one variable and information between delimiter in another variable. Need to continue doing until it reaches end of file.
test.txt
-------------------------
delimiter: "--@--"
--@--
name:"section1"
This is section 1 with some information
--@--
name:"section2"
This is section 2 with some information
--@--
name:"section3"
this is section 3 with some information
--@--
End of file
i appreciate all the help i get. Thanks!
considering your text file content is in $string and delimiter is $delim, a preg_match_all and a array_combine will help you with this
it should return somthing like this: