When XML response contains only one count element, json_decode(json_encode($xml))
produces a flat array instead of nested, causing $arr to be a string.
Skip non-array entries to avoid "Cannot access offset of type string on string".
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
$maas = json_decode(json_encode($xml), true);
asort($maas);
foreach ($maas["count"] ?? [] as $id => $arr) {
+ if (!is_array($arr)) {
+ continue;
+ }
//echo"<br>DateTime=".$arr["DateTime"]." $id =>".$arr["CameraName"]." CameraID=".$arr["CameraID"]." value=".$arr["Value"]." " ;