I am trying to pull out a bunch keywords from my last 200 tweets but so far using ‘substr_count’ only allows me to search one string at a time.
Is there a way to define an array of keywords and use ‘substr_count’ to count all of them for me?
$recentTweets = $connection->get('https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=username');
GLOBAL $textDump;
for ($i=0; $i<count($recentTweets); $i++){
$textDump .= $recentTweets[$i]->text . " ";
};
$keyWords = "the";
$number = substr_count(strtolower($textDump), strtolower($keyWords));
echo $number;
1 Answer