Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End If status contains @tag then..?

  • This topic is empty.
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)
  • The forum ‘Back End’ is closed to new topics and replies.