我正在尝试在给定字符串中创建一个包含所有哈希标签的数组,然后遍历它们并回显每个标签以显示它们已被存储。我可能做错了什么?
<?php
$string= "Went for an awesome bike ride today! #biking";
preg_match_all('/#(\w+)/',$string, $matches);
foreach ($matches as $tag) {
echo $tag;
}
?>