I have a URL like http://example.com - The HTML source of it is:
<html>
test
test2
{"customer":{"email":null,"is_eu":true"}
t
</html>
I want to get the JSON only from it then get anything from this JSON
My current code is here:
$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'];
But the result is empty page.
EDIT: The result of echo print_r($json, true)
is:
Array ( [0] => {"customer":{"email":null,"is_eu":true} )
Any help would be appreciated.
Thanks!