I have a PHP single dimension array, when using the json_encode function on that array I get a json object returned but it has a leading 0 before the opening curly brace {.
0{"a1000":"b1000","a1200":"b1200"}
The PHP array is:
Array
(
[a1000] => b1000
[a1200] => b1200
)
On the same page, with a different (but same structured) request, the json object that is returned does not have a leading 0.
The error in the Chrome console is:
Uncaught SyntaxError: Unexpected token {
Has anyone ever come across this problem before?
Your PHP is likely outputting the
0before the JSON. Although you didn’t show all you code, you should double check all of the following:<?phptagechoorprintstatementsreadfile()orvar_dump()