我想从一个字符串中提取所有#个单词,例如,如果我有这个字符串:
P
我需要一个PHP函数,将这些返回给我:
using FuncType = void(int);
// These two declarations are exactly the same
void doAThing(FuncType* callback);
void doAThing(void(*callback)(int));
答案 0 :(得分:0)
这是我应用您的请求的示例
$string = "Hello #people how are you doing #today I am in #asia and weather is super #nice";
$regex = '~(#\w+)~';
if (preg_match_all($regex, $string, $matches, PREG_PATTERN_ORDER)) {
foreach ($matches[1] as $word) {
echo $word .'<br/>';
}
}