getting empty array results using preg_match_all for values that don't match

kakamokoloko

New Member
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\[code\]$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;}\[/code\]results in:\[code\]Array ( [0] => Array ( ) [1] => Array ( ) )\[/code\]Expected results:\[code\]Array();\[/code\]
 
Back
Top