2012-03-02 84 views
0

我試圖獲得iPhone正確的JSON輸出我使用的代碼:正確的JSON輸出中iPhone json_encode

<?php 
$post = array('items' => 1, 'title' => message, 'description' => description); 

echo json_encode($post); 
?> 

,輸出是:

{"items":1,"title":"message","description":"description"} 

但我想要一個輸出與[

{ 
    "items": [ 
      { 
       "title": "message", 
       "description": "description" 
      } 
     ] 
} 

有人可以告訴我該怎麼做嗎?

回答

1

嘗試

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

(警告:未經測試)

+0

警告:英雄。 :) – Frenck 2012-03-02 18:01:23