if ($_POST['id'] beginsWith "gm") {
$_SESSION['game']=="gmod"
}
if ($_POST['id'] beginsWith "tf2") {
$_SESSION['game']=="tf2"
}
How to do this so it will work?
To check if string starts with a specific character, use PHP built-in function strpos(). Provide the string and character as arguments to strpos(), and if strpos() returns 0, then we can confirm that the string starts with the specific character, else not.
In order to check if a string is a date or not, you can use the strtotime() method. Note: The strtotime() method functions by parsing an English datetime string into a UNIX timestamp.
You could use substring
if(substr($POST['id'],0,3) == 'tf2')
{
//Do something
}
Edit: fixed incorrect function name (substring()
used, should be substr()
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With