title: PHP exec response as string?
body: <p>I currently use the installed version of curl via exec() instead of using curl_exec() to query an API (linkedin). My call returns the good result but is weirdly encoded and I cannot transform it back to json.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>exec('curl "'.$url.'/v1/people/~?format=json" -H "Authorization: Bearer '.$token.'"', $data);
  </code></pre>
  
  <p>The response I get is (i replaced sensitive data with xxxx):</p>
  
  <blockquote>
    <p>array(7) { [0]=> string(1) "{" [1]=> string(22) " "firstName":
    "xxxx"," [2]=> string(67) " "headline": "xxxx;"," [3]=> string(21) "
    "id": "xxxx"," [4]=> string(24) " "lastName": "xxxx"," [5]=>
    string(148) " "siteStandardProfileRequest": {"url":
    "<a href="https://www.linkedin.com/profile/view?id=xxxx&amp;authType=name&amp;authToken=xxxx&amp;trk=api" rel="nofollow">https://www.linkedin.com/profile/view?id=xxxx&amp;authType=name&amp;authToken=xxxx&amp;trk=api</a><em>xxxx</em>xxxx*"}"
    [6]=> string(1) "}" }</p>
  </blockquote>
  
  <p>I've tried <code>json_encode(json_decode($data))</code> but it doesn't change anything... How can I transform this output into a JSON object?</p>