- var_dump: documentation ( source)
- array_count_values: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$string = <<<POST
wow, that film was #hilarious
I #love turtles
#YouTube has funny videos that I #love <3
POST;
preg_match_all('/#(\w+)\b/', $string, $matches);
var_dump(array_count_values($matches[0]));