Array
(
[0] => This
[1] => is
[2] => a
[3] => search
[4] => term
)
Array
(
[0] => Array
(
[title] => This is a video title.
[description] => This is a video description. It contains words and stuff.
)
[1] => Array
(
[title] => Words. Wooo!
[description] => This is also a video description.
)
)
I want to count each occurrence of a keyword in every element in the video array and then combine the total matches and put them into one array like this:
Array
(
[0] => Array
(
[title] => This is a video title.
[description] => This is a video description. It contains words and stuff.
[matches] => 6
)
[1] => Array
(
[title] => Words. Wooo!
[description] => This is also a video description.
[matches] => 3
)
)
This is where I'm stuck.I was thinking about using str_replace() to count the occurrences, but every way I turn this it requires me to run a loop inside a loop, which as far as I know is not possible.
So, if anyone has a brilliant solution that I'm too slow to figure out myself, please do share
