What I want to do is the following:
$data = json_encode($result, true);
echo $data;
Use json_decode($json_string, TRUE)
function to convert the JSON object to an array.
Example:
$json_string = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
$my_array_data = json_decode($json_string, TRUE);
NOTE: The second parameter will convert decoded JSON string into an associative array.
===========
Output:
var_dump($my_array_data);
array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}