title: Extract JSON from HTML source and use it
body: <p>I have a URL like <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a> - The HTML source of it is:</p>
  
  <pre><code>&lt;html&gt;
  test
  test2
  {"customer":{"email":null,"is_eu":true"}
  t
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to get the JSON only from it then get anything from this JSON</p>
  
  <p>My current code is here:</p>
  
  <pre><code>$whole_html = htmlspecialchars(file_get_contents("http:/example.com"));
  preg_match('~\{(?:[^{}]|(?R))*\}~', $whole_html, $json);
  $JsonResults = print_r($json, true);
  $json_decoded = json_decode($JsonResults, true);
  echo $json_decoded['customer']['email'];
  </code></pre>
  
  <p>But the result is empty page.</p>
  
  <p><strong><em>EDIT</em></strong>: The result of <code>echo print_r($json, true)</code> is:</p>
  
  <pre><code>Array ( [0] =&gt; {"customer":{"email":null,"is_eu":true} )
  </code></pre>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks!</p>