Hi all,
What I am trying to accomplish is this:
- User submits form
- PHP checks the form for any words that begin with the '#' hash symbol
- If any words beginning with # are found, php checks database to see if it already exists
What is the best way to do this?
Please keep in mind that the form being checked for these words will contain up to 200 character, and may contain more than one hashtagged word.
I imagine that the flow would look vaguely like this:
form submitted > check for #hashtagged words > put those words in an array > loop through array and check DB if it already exists > return results to user
The step from above that I need help on is finding the words and putting them into an array.
I've managed to figure out how to convert those words to links using preg_replace. In case it helps anyone, here it is below:
preg_replace('/(#\w+)/', '<a href=\'http://yourwebsite.com/script.php?get=\1\'>\1</a>', $string);
Thanks in advance for your time!