Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default Best way to do this?

    What would be the best way to do the following:
    In a shoutbox, you type in "/ban Jack", whats the best way of checking if:
    /ban is at the beginning of the string

    So if someone types in "the command is /ban jack" it wont do anything?

  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:
    <?php

    $string 
    '/ban lol';

    if( 
    preg_match'/^\/ban (.*)$/i'$string$match ) )
    {

        
    $username $match];
        echo 
    $username;

    }

    ?>

  3. #3
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    PHP Code:
    <?php

    $string 
    '/ban lol';

    if( 
    preg_match'/^\/ban (.*)$/i'$string$match ) )
    {

        
    $username $match];
        echo 
    $username;

    }

    ?>
    Thank you Simon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •