Hi there,

I'm currently trying to find a way of searching a submitted string and if it has a ! at the begining of the string then I can wrap the string in a font colour in the if statement.

This is basically for a chatbox mod. If there is a ! at the begining and the user is an admin then the font changes colour to make it obvious it is an admin shout.

$shout = "!this is an administrator shout";

if($user == ADMIN && [ADDITIONAL CHECK HERE]) 

Does anyone know what function to use for that?.

Thanks. 🙂

    if( $user == "ADMIN" && substr($shout, 0, 1) == "!" )
    {
       // ...
       // do whatever
       // ...
    }
    

      Just to help you out. substr takes up to 3 parameters.

      substr($string, $start, $end);
      

      $string is the variable that you want to search
      $start is the integer that you want to start looking. Remember that PHP starts at 0.
      $end is the integer you wish to end at.

      In your case $string is "!this is an administrator shout". $start is 0 because we want to start at the beginning and $end is 1 because we only want to look at the first character.

        Write a Reply...