Skip to main content

Forums

This topic contains 5 replies, has 0 voices, and was last updated by  schart 6 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36609

    schart
    Participant

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

    #96583

    bungle
    Member

    $words = explode(" ",$comment);
    foreach ($words as $word) {
    $match = preg_match("/B@[^B]+/",$word,$matches);
    if ($match==1) {
    $username = substr($matches[0],1);
    echo $username;
    }
    }
    #96597

    bungle
    Member

    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-link icon-logo-star icon-search icon-star