Some issue fixed here http://sdtuts.com/php-convert-hash-into-hashtags-from-content/ Demo link: http://demos.sdtuts.com/php_hash_tag