Frenck
Frenck

Reputation: 6534

Correct JSON ouput iPhone json_encode

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

Answers (1)

Ben Clayton
Ben Clayton

Reputation: 82219

try

$post = array('items' => array( 0 => array('title' => message, 'description' => description)));

(warning: untested!)

Upvotes: 1

Related Questions