I have a JSON (Line A) as shown below in which I want to calculate the number of items in a JSON object array.
$fp = fopen('../feeds/ptp-ess_landing.json', 'w');
fwrite($fp, json_encode($output));
fclose($fp);
logActivity();
if(file_exists('../feeds/ptp-ess_landing.json')){
$data = json_decode(file_get_contents('../feeds/ptp-ess_landing.json'));
}
{"toggle_multi_tiles":["0","1"]} // Line A
At this moment, it is 2. It can be three as well or sometimes 4.
This is what I have tried:
$data->toggle_multi_tiles.length; // Line B
On doing echo $data->toggle_multi_tiles.length;
it returns Arraylength
which is not the right output I am getting.
Problem Statement:
I am wondering what changes I should make in the php code above at Line B so that it returns 2.