i have data of set like this:
$data[] =
Array
(
[u_d] => ABCDEF
[0] => Array
(
[one] => oned
[two] => 222
[three] => three
[four] => 444
[five] => 555
[events] => Array
(
[0] => Array
(
[feed] => Array
(
[0] => Array
(
[date-time] => 191018080000
[sub-type] => abc
[comments] => test comments
[parameter-list] => para1, para2
[state] => bad
[value] => 1000
)
)
)
)
)
[1] => Array
(
[one] => two
[two] => 224562
[three] => thyyree
[four] => 445344
[five] => 5345355
[events] => Array
(
)
)
)
I need to fetch the event only and remove the empty events. However first i tried to fetch the events liket this, But it give an error.
$new = [];
for($i=0 ; $i < count($data)-1 ; $i++)
{
if(count($data[$i]['events']) > 0)
{
$new[] = $data[$i]['events'];
}
}
print_r ($new);
But it give me an error : Cannot use object of type Illuminate\Http\JsonResponse as array
Can anyone please help me to resovle the issue?
Thank you
json_decode($data)First u need to decode json first. After that u can access their value in php way.$data[$i]->events