Match Phrases (in array) in text string
- by Tim Hanssen
I'm using the Twitter API streaming to collect thousand of tweets every minute.
They need to be matched to a list of keywords (can contain spaces).
This is my current method:
$text = preg_replace( '/[^a-z0-9]+/i', ' ', strtolower( $data['text'] ) );
$breakout = explode( " ", $text );
$result = array_intersect( $this->_currentTracks, $breakout );
I chop the tweet into words, and the matches them against my current keywords.
This works well for all the keywords without a space ofc.
If I wanted to find for example "Den Haag", It won't show up, because the string is exploded into words (based on the spaces).
Any ideas about how I can do this in a quick way?
Kind regards,
Tim