In a string each time there is a word with a # I want to save the word in an array, here my code :
<?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;
?>
But I don't know how to put each new word in a new cell of the array $hash_tag and i really need help on this one