I have no idea why this is not working. The count comes back with the correct size for the array.
Here's the mWeb.json file:
[{"Title": "Some-Name","h1": "Some-h1-words", "Comments": "Some Comment", "Comments2": "Some Comment2"},
{"Title": "Some-Name b","h1": "Some-h1-words b", "Comments": "Some Comment b", "Comments2": "Some Comment2 b"},
{"Title": "Some-Name c","h1": "Some-h1-words c", "Comments": "Some Comment c", "Comments2": "Some Comment2 c"}]
Here's the code:
<?
$url = 'mWeb.json';
$JSON = file_get_contents($url);
$someName = "Some-Name";
$data = json_decode($JSON);
echo count($data);
for($x=0; $x<count($data); $x++){
if($data[$x]['Title']==$someName){
echo '[{"Title":"'.$data[$x]["Title"].'","h1":"'.$data[$x]["h1"].'","Comments":"'.$data[$x]["Comments"].'","Comments2":"'.$data[$x]['Comments2'].'"}]';
}
}
?>
All the echoes is the length of the array - echo count($data);