I\'ve got following XML:
123
ACTIVE
>
I cannot add a comment, but I think this will work for you, it should be faster then a regex or a loop:
//after you json_encode, before you decode
$str = str_replace(':[]',':null',json_encode($array));
An empty array in JSON is represented by "[]
". Sometimes the arrays are parsed as objects, in that case (or as a fallback) you can replace ":{}
" too.