I'm performing a search on a text file (to be more specific, the OFAC report on the US Treasury Site). Basically, what I'm doing is fetching the file and putting the contents into a variable via file_get_contents. Then performing a strstr with the search text and the OFAC variable. What I need to do is if it finds the string, i want to extract all the text starting with the double-line break before the term was found and end with the double-line break after the term was found. For example, here's what i'm trying to do:
So in the above example, if the user searched for "when i say longer", I would want it to get the entire 2nd paragraph. if they searched for "separate from other paragraphs", I would want to display the entire first paragraph. Does that make sense? Is this possible?
Code:
this is some text that would be found on the ofac report. it's a paragraph of it's own. it is separate from other paragraphs.
this is another paragraph similar to one that would be found on the ofac report. it's much longer than the first paragraph, and when i say longer, i mean it has more words in it. this paragraph contains more letters, spaces, and punctuation than the paragraph before it. i guess that's what makes it longer. i could've used lorem ipsum but i decided this would be funner.
this is the last paragraph. it's not long at all.
So in the above example, if the user searched for "when i say longer", I would want it to get the entire 2nd paragraph. if they searched for "separate from other paragraphs", I would want to display the entire first paragraph. Does that make sense? Is this possible?