- preg_match_all: documentation ( source)
- var_export: documentation ( source)
<?php
$string = '@mention_1 @$badmention Manual balls knit cardigan @120rb
email me @ example@example.com';
$count = preg_match_all(
'/(?:^|\s)@\K\w+/',
$string,
$matches
);
var_export([
'count' => $count,
'matches' => $matches[0]
]);