Forums

  • # February 11, 2012 at 5:26 pm

    All I need is a PHP scripts that detects if the variable “comment” includes any ” @username ” – and then get that username without the “@” :)

    # February 12, 2012 at 1:11 pm

    $words = explode(" ",$comment);
    foreach ($words as $word) {
    $match = preg_match("/B@[^B]+/",$word,$matches);
    if ($match==1) {
    $username = substr($matches[0],1);
    echo $username;
    }
    }
    # February 12, 2012 at 7:43 pm

    Your method will only find the first username in a comment though.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag