- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
- implode: documentation ( source)
<?php
$str = '#helloworld #test #video #youtube Bon Iver are the best daily surprise :D';
preg_match_all('/#([^\s]+)/', $str, $matches);
$hashtags = implode(',', $matches[1]);
var_dump($hashtags);