title: PHP string explode on space, except when in quotes
body: <p>I have a problem similar to <a href="https://stackoverflow.com/questions/2202435/php-explode-the-string-but-treat-words-in-quotes-as-a-single-word">this question</a>, however with one more twist. </p>
  
  <p>I want to explode the following string:</p>
  
  <pre><code>title:"tab system" color:="blue" price:&gt;10
  </code></pre>
  
  <p>into</p>
  
  <pre><code>array("title:\"tab system\"", "color:=\"blue\"", "price:&gt;10")
  </code></pre>
  
  <p>Here's what I've tried so far from the above link:</p>
  
  <pre><code>$text = "title:\"tab system\" color:=\"blue\" price:&gt;10";
  preg_match_all('/"(?:\\\\.|[^\\\\"])*"|\S+/', $text, $matches);
  print_r($matches);
  </code></pre>
  
  <p>Which produces:</p>
  
  <pre><code>(
      [0] =&gt; title:"tab
      [1] =&gt; system"
      [2] =&gt; color:="blue"
      [3] =&gt; price:&gt;10
  )
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>print_r(str_getcsv($text, ' '));
  </code></pre>
  
  <p>which produces the same thing.</p>
  
  <p>These solutions don't work for me because as you can see, it's possible that the quotes may not start next to the delimiter (in this case, a space). Also, that's just one example of an input string, there could be many variations of it.</p>