Use preg_match_all()
with a positive lookahead to extract all the required strings:
(?<=\s)@(\w+)
Explanation:
(?<=\s)
- if preceded by a whitespace character@
- match literal@
character(\w+)
- match (and capture) any word character[A-Za-z0-9_]
Code:
$ok = preg_match_all('/(?<=\s)@(\w+)/', $tagPossible, $matches);
if ($ok) {
$arr = $matches[1];
}
print_r($arr);
Output:
Array
(
[0] => nokiadeveloper
[1] => nokia
)