title: How to parse Comma delimited string with newline to JSON in PHP to use with Morris.JS
body: <p>I send SOAP API requests to a Service, but the response comes in one field  and consists of a string :</p>
  
  <pre><code>$string = '"users","actions","movements" "user1","111","54" "user2","87","123" "user3","92","23"'
  </code></pre>
  
  <p>when i do:</p>
  
  <pre><code>$json = json_encode($string);
  </code></pre>
  
  <p>does not result in valid <code>JSON</code>.</p>
  
  <p>I've tried :</p>
  
  <pre><code>$Data = str_getcsv($incomingdata, "," , '"' , "\n"); 
  $json2 = json_encode($Data);
  </code></pre>
  
  <p>It is not parsed correctly to use with MORRIS.JS and results in complete rubbish</p>
  
  <p>The "users","actions","movements" are the headers.
  Could someone point me in the right direction please ?</p>
  
  <p>The needed result should look like this:</p>
  
  <pre><code>[0] =&gt; Array
          (
              [user] =&gt; user1
              [actions] =&gt; 630
              [movements] =&gt; 87
          )
  [1] =&gt; Array
          (
              [user] =&gt; user2
              [actions] =&gt; 330
              [movements] =&gt; 187
          )
  </code></pre>
  
  <p>and so on</p>