I am trying to json_encode an array which is returned from a Zend_DB query.
var_dump gives: (Manually adding 0 member does not change the picture.)
a
Added information that expands on Seb's answer.
php > print json_encode( array( 'a', 'b', 'c' ) ) ;
["a","b","c"]
php > print json_encode( array( 0 => 'a', 1 => 'b', 2 => 'c' ) ) ;
["a","b","c"]
php > print json_encode( array( 1 => 'a', 2 => 'b', 3 => 'c' ) ) ;
{"1":"a","2":"b","3":"c"}
php >
Note: its formatting it this way with good cause:
If you were to send
{"1":"a","2":"b","3":"c"}
as
["a","b","c"]
When you did $data[1]
in Php you would get back "a", but on the JavaScript side, you would get back "b" .