文字列に # を持つ単語があるたびに、その単語を配列に保存したいのですが、ここに私のコードがあります:
<?php
function tag($matches)
{
$hash_tag = array();
$hash_tag[]=$matches[1];
return '<strong>' . $matches[1] . '</strong>';
}
$test = 'this is a #test1 #test2 #test3 #test4 #test5 #test6';
$regex = "#(\#.+)#";
$test = preg_replace_callback($regex, "tag", $test);
echo $test;
?>
しかし、新しい単語を配列 $hash_tag の新しいセルに入れる方法がわかりません。これについて本当に助けが必要です