I have a .txt file called 'test.txt' that is a JSON array like this:
[{"email":"[email protected]","createdate":"2016-03-23","source":"email"}]
I'm trying to use PHP to decode this JSON array so I can send my information over to my e-mail database for capture. I've created a PHP file with this code:
<?php
$url = 'http://www.test.com/sweeps/test.txt';
$content = file_get_contents($url);
$json = json_decode($content,true);
echo $json;
?>
For some reason, it's not echoing the decoded JSON when I visit my php page. Is there a reason for this and can anyone shed some light? Thanks!
print_r($json);and/or loop over it and echo the elements.$foo = array('a','b'); echo $foooutputs the literal wordArray, not the contents of the array. you cannot echo/print arrays directly.