Php 如何仅获取@symbol后面的用户名
我有这个代码,它完全符合我的要求。 然而,它只为一个用户名,我想知道我如何才能做到这一点,使它得到多个用户名从它Php 如何仅获取@symbol后面的用户名,php,preg-match,Php,Preg Match,我有这个代码,它完全符合我的要求。 然而,它只为一个用户名,我想知道我如何才能做到这一点,使它得到多个用户名从它 $string = 'Tweet @one two @three four'; preg_match("/@(\\w+)/", $string, $matches); $hash1 = $matches[1]; echo $hash1; $hash1返回“一”。使用 preg\u match\u all 请看这里使用功能: $string = 'Tweet @one two @th
$string = 'Tweet @one two @three four';
preg_match("/@(\\w+)/", $string, $matches);
$hash1 = $matches[1];
echo $hash1;
$hash1返回“一”。使用
preg\u match\u all
请看这里使用功能:
$string = 'Tweet @one two @three four';
preg_match_all("/@(\w+)\b/", $string, $matches, PREG_SET_ORDER);
print_r($matches);