- preg_match_all: documentation ( source)
<?php
$string= "Went for an awesome bike";
echo $string . "</br></br>";
preg_match_all('/#(\w+)/',$string, $matches);
if ( count( $matches[1]) != 0) {
foreach ($matches[1] as $tag) {
echo $tag . "</br></br>";
}
}
else {
echo "There are no tags here!!";
}