I don't understand why are you replacing the command and explode is still confusing. I went to tizag and w3schools and still don't undersrand how to use explode.
and you want hello and blah separate strings so explode would break that string into 2 parts by the - like this
$example = explode("-","Hello-blah");
Now the first part is saying hey I want to get rid of that - and make the everything before it 1 string and everything after another. So now $example[0] = "Hello" and $example[1] = "blah"
Get that part?
Then you are replacing the /ban or whatever because you want to check to see if it was that command or not and it also makes it easier to use such as for 1 work commands all you gotta do is just query the rest of the string into your database which saves you time later and for 2 or more word commands use explode() to separate the string but not replacing it because you still need both parts
Get it?
Also explode('-','Hello-blah-meh',1)
Makes it so that is once it separate the first word it will stop and then the second c part will be what's next in this case it would be blah-meh
lol you replace because of this so lets say your command is "/ban drago I hate you" and you just need to explode the name and the reason and not the command so you just replace out the /ban because you don't even need it
What I'm doing is:
if(substr($yourpostvar, 0, 4) == '/ban' && $_SESSION['admin'] == '1'){
$arr = explode("/", $yourpostvar);
$qs = "INSERT INTO bans (user, reason) VALUES('".$arr[2]."', '".$arr[3]."')";
$q = mysql_query($qs) or die(mysql_error());
}
This code would let you ban a user by typing a command like this: /ban/USER/REASON
Change $yourpostvar obviously. If you want a different command, simply change the substr($yourpostvar, 0, 4) == '/ban' part. Change the 4 with the number of characters your new command would take with the first chunk, ie. /away is 5 characters, /pm is 3 characters, and so on.
Without stories, we wouldn't be human beings at all. -- Philip Pullman // 09F911029D74E35BD84156C5635688C0