I have JSON script that return some data but sometimes its empty and my foreach loop throws out an error when its empty here is my code
<?php
$planItems = getJSON('getPlanItems');
foreach ((array)$planItems->items as $item){
?>
I notice its because of
$planItems->items
Removing the -> doesnt throw out the error but then I cant read the result correctly from the JSON data.
Is there anyway to fix this?
var_dump(getJSON('getPlanItems'));??