Jump to content

Match end of string


TEENFRONT

Recommended Posts

Hey

 

i have a string thats, example

 

$string = "Kick user XXXXXXXXXXXX";

 

XXXXXXXX  could be anything (in this case its a user ID but can be anything)

 

How can i see if string has "kick user" in it.

 

im using it in an if statement like this

 

if($message = "ban user" || $message == "kick user xxxxxxx")

 

but as said, the xxxx could be anything so it wont match.

 

any help?

Link to comment
https://forums.phpfreaks.com/topic/165440-match-end-of-string/
Share on other sites

Hey there,

 

You'll wanna take a look at the PHP strstr() function for this. I'm including a little code example to get you going, but the best resource for learning about the function is at:

http://www.php.net/manual/en/function.strstr.php

 

<?php
// get last directory in $PATH
$text = "dude wheres my car user";
$test = "kick user dsdf3243221sad";

// get everything after last newline

if (strstr($test, "kick user"))
        echo "true";
   else
        echo "false";
?>

Link to comment
https://forums.phpfreaks.com/topic/165440-match-end-of-string/#findComment-872590
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.