I have a json like this:
{
"data": [
{
"prop1":"aaa",
"prop2":"bbb",
"prop3":"1234",
"prop4":"2006"
},
{
"prop1":"ccc",
"prop2":"ddd",
"prop3":"4567",
"prop4":"2016"
},
{
"prop1":"aaa",
"prop2":"ddd",
"prop3":"4567",
"prop4":"2002"
}
]}
It will have ~100 elements and I need to count elements with specified property, I tried something with
echo count($json['data']);
but it will get me count of all elements of json - I need to know the number of elements with prop1 => "aaa"
what I have so far:
$file = "test.json";
$fh = fopen($file, 'a') or die();
$json = json_decode(file_get_contents($file), true);
echo '<pre>';
print_r($json);
exit();
?>