If I have a lot of content stored in a variable, how do I find each occurrence of a certain word. For example, I want to find the word grand and then grab the word that follows it.
Basically, I want to check each time the word grand is used then save the following word in my database.
Let's say I set it up like this.
$story = "The princess went to the grand ball by herself. She was waring a yellow dress and grand shoes. While there, she dance with lots of men but one was a grand prince. He lived another village in a grand castle."
So, I need to run some sort of a for loop that is going to pick out the words "ball", "shoes", "prince", and "castle".
How can I do this?
Basically, I want to check each time the word grand is used then save the following word in my database.
Let's say I set it up like this.
$story = "The princess went to the grand ball by herself. She was waring a yellow dress and grand shoes. While there, she dance with lots of men but one was a grand prince. He lived another village in a grand castle."
So, I need to run some sort of a for loop that is going to pick out the words "ball", "shoes", "prince", and "castle".
How can I do this?