I am using preg_match_all to search for HashTag values in a Twitter Search response.
It works as I expected except for when the search results don't have any hash values in them. For some reason my $tags array still has values and I'm not sure why.
Is it because my RegEx is not correct, or is it a problem with preg_match_all?
Thanks
$tweet = "Microsoft Pivot got Runner-Up for Network Tech from The Wall Street Journal in 2010 Technology Innovation Awards http://bit.ly/9pCbTh";
private function getHashTags($tweet){
$tags = array();
preg_match_all("/(#\w+)/", $tweet, $tags);
return $tags;
}
results in:
Array ( [0] => Array ( ) [1] => Array ( ) )
Expected results:
Array();