I'm creating my own version of twitter, I have no idea how to get my back end php script to pick up the @membername within the entered text. Including multiple @membername's for example @billy @joseph, @tyrone,@kesha message
or
@billy hit up @tyrone he's bugging @kesha about the money you owe him.
Any scripts of use on how I can accomplish this?
All depends on how you set it up...Can your user names have a space in it? If not, then just simply parse the message string for "@" and pick up all characters that come after until you encounter a space...that's a real simple way to get it done.
The other side of the question is what are you doing with the usernames once you do "find" them?
There is a PHP library designed to conform to Twitter's standards. It might save you a lot of hassle. It supports autolinking as well as extraction for @screen_names, #hashtags, and @screen_name/lists.
http://github.com/mzsanford/twitter-text-php
I wrote a Wordpress plugin that handles this a long time ago. Here's the function that I use for this.
What about using a regex and
preg_match_all
, like this :Which would give you the following output :
Basically, here, the pattern I used in my regex is matching :
@
character\w+