I've got a script that explodes an input, see below:
$message = explode(" ", $_GET['message']);
switch($message[0])
{
case "/commands":
echo "N/A";
break;
case "/mute":
$player = $message[1];
$time = $message[2]; // seconds
$reason = $message[3];
echo "Mute {$player} for {$time} seconds because {$reason}";
break;
default:
echo "Invalid command";
break;
}
I've stumbled into an issue, say the user was to use "/mute Steve 500 For being an idiot" - it would return to me "Mute Steve for 500 seconds because For"
instead of providing me with the full reason, because I've used $message[3]
, I'm asking you this:
How do I return everything after $message[2]
?
Would I have to run a foreach loop, combining all the words together, or is there an easier method?
Sorry if it's hard to understand, I tried explaining the best I could, but it's a hard topic to explain.