There are a lot of great answers here - but I found my issue was quite a bit more simple.
I was trying to run the following command:
$x['name'] = $j['name'];
and I was getting this illegal string
error on $x['name']
because I hadn't defined the array first. So I put the following line of code in before trying to assign things to $x[]
:
$x = array();
and it worked.