What I would like to do is be able to find occurences in a text file and replace them.
I have a text file synonyms.txt
each line looks like this
a week|per week
places to go|places to check out|places to visit|places you can see
next i have a text string say like
$text = "What a week. It was amazing. The places to go were great."
What I would like it to do, is open the file synonyms.txt
find all 3 word occurences and then check them within the $text and replace the text.(such as "places to go")
Then all 2 word occurence and check them(such as "per week" and "a week")
Then all 1 word (brilliant,amazing etc)
then to output a random variety of it.
such as "What per week. It was excellent. The places to visit were excellent."
thank you for any help.