Reputation: 6534
I'm trying to get a correct json output for iPhone i'm using the code:
<?php
$post = array('items' => 1, 'title' => message, 'description' => description);
echo json_encode($post);
?>
And the output is:
{"items":1,"title":"message","description":"description"}
But i want a output with [
{
"items": [
{
"title": "message",
"description": "description"
}
]
}
Can someone tell me how to do that?
Upvotes: 0
Views: 89
Reputation: 82219
try
$post = array('items' => array( 0 => array('title' => message, 'description' => description)));
(warning: untested!)
Upvotes: 1