Q:

Why php json_encode encodes two dimensional array but outputs pure array

$my_array = array(
        0 => array(
                1,
                2,
                3,
            ),
        1 => array(
                1,
                2,
                3,
            ),
        2 => array(
                1,
                2,
                3,
            ),
    );
echo json_encode($my_array);

Result is this:
[[1,2,3],[1,2,3],[1,2,3]]

I thought the output should be a string of json,but here outputs a pure array,why?In other words,the result should be quoted,but why this is not.

A:

Use JSON_FORCE_OBJECT with json_encode()
echo json_encode($my_array, JSON_FORCE_OBJECT);

Program Output
{"0":{"0":1,"1":2,"2":3},"1":{"0":1,"1":2,"2":3},"2":{"0":1,"1":2,"2":3}}

DEMO

