Fetching tags from content with PHP

For example, the content is:

Hello, world.
This is the one of tech place: #laravel.

#tech #coding #ceil

I want to fetch start with ‘#’ as tags and insert to tags table, so how to do this?

class Tag
public static function fetchesResolved($value)
$matches = [];
if (! empty($value)) {
preg_match_all("/(#\w+)/u", $value, $matches);
if (empty($matches)) {
$hashtagsArray = array_count_values($matches[0]);
$hashtags = array_keys($hashtagsArray);
return preg_replace('/#([\w-]+)/u', '$1', $hashtags);

Finally, you can call Tag::fetchesResolved($content) and get the array of tags like this: