here is my code :
$response = $obj->toArray();
$encoded = json_encode($response, true);
header('Content-type: application/json');
exit($encoded);
and the result is somtimes like :
[ {"id":"1","value":"COM1"} , {"id":"2","value":"COM2"} ]
and I want it a pure json like :
{ "0" : {"id":"1","value":"COM1"} , "1" : {"id":"2","value":"COM2"} }
please help me.