Q:

PHP - printing out an array does not seem to produce what I intended

I am using PHP and trying to create an array that looks something like this:
{
    "aps" : {
        "alert" : "Hey"
    },
    "custom_control" : {
        "type" : "topic_comment",
        "object":{
            "topic_id":"123",
            "topic_section":"test"
                        "plan_id":"456"
        }
    }
}

The code I have is:
 <?php
    $message = array(
        "aps" => array(
            "alert" => "hey"
        ),
        "custom_control" => array(
            "type" => "topic_comment",
            "object" => array(
                "topic_id" => "123",
                "topic_section" => "abc",
                "plan_id" => "456"
            )
        )
    );

print_r($message);
?>

but what is printed out is this:
Array ( [aps] => Array ( [alert] => hey ) [custom_control] => Array ( [type] => topic_comment [object] => Array ( [topic_id] => 123 [topic_section] => abc [plan_id] => 456 ) ) )

It seems like this is a totally different format from what I had intendd. Or am I incorrect in some way?
Thanks,
Alex

A:

It seems like you forgot to json_encode your $message variable.
<?php echo json_encode($message); ?>

