I\'m building a PHP script that feeds JSON data to another script. My script builds data into a large associative array, and then outputs the data using json_encode
json_encode
I had the same issue.
Anyway I just used the json formatting code here:
http://recursive-design.com/blog/2008/03/11/format-json-with-php/
Works well for what I needed it for.
And a more maintained version: https://github.com/GerHobbelt/nicejson-php