How to parse console command strings in PHP with quotes
<p>For my game I'm coding a console that sends messages via AJAX and then receives output from the server.</p>

<p>For example, an input would be:</p>

<pre><code>/testmessage Hello!
</code></pre>

<p>However, I would also need to parse the quotes e.g.:</p>

<pre><code>/testmessage "Hello World!"
</code></pre>

<p>However, since I am simply exploding the string with spaces, PHP sees <code>"Hello</code> and <code>World!"</code> as separate parameters. How do I make PHP think that "Hello World!" is one parameter?
Right now I'm using the following code to parse the command:</p>

<pre><code>// Suppose $inputstring = '/testmessage "Hello World!"';
$inputstring = substr($inputstring, 1);

$parameters = explode(" ", $inputstring);

$command = strtolower($parameters[0]);

switch ($command) {
    case "testmessage":
        ConsoleDie($parameters[1]);
        break; 
}
</code></pre>

<p>Thank you in advance.</p>
