我正在使用期望这种 JSON 格式的 jQuery 日历:
string(138) "[{"title":"Event1","start":"2012-06-10"},{"id":222,"title":"Event2","start":"2012-06-20","end":"2012-06-22","url":"http:\/\/yahoo.com\/"}]"
但是,我得到的是:
[{"title":"Event1","start":"2012-06-10"},{"id":222,"title":"Event2","start":"2012-06-20","end":"2012-06-22","url":"http:\/\/yahoo.com\/"}]array(2) { [0]=> array(2) { ["title"]=> string(6) "Event1" ["start"]=> string(10) "2012-06-10" } [1]=> array(5) { ["id"]=> int(222) ["title"]=> string(6) "Event2" ["start"]=> string(10) "2012-06-20" ["end"]=> string(10) "2012-06-22" ["url"]=> string(17) "http://yahoo.com/" } }
问题是一个说它是一个string(138)
,而另一个是一个array
。
这是我的代码:
$myHolder = array();
$myHolder[] = array(
'title' => "Event1",
'start' => "$year-$month-10",
);
$myHolder[] = array(
'id' => 222,
'title' => "Event2",
'start' => "$year-$month-20",
'end' => "$year-$month-22",
'url' => "http://yahoo.com/"
);
echo json_encode(($myHolder));