$cnt = 0;
while ($row = $result->fetch_assoc())
{
$arre[$cnt]['id'] = $row['idevents'];
$arre[$cnt]['title'] = $row['title'];
$arre[$cnt]['start'] = "new Date(" . $row['start'] . "*1000)";
$arre[$cnt]['end'] = "new Date(" . $row['end'] . "*1000)";
$arre[$cnt]['allDay'] = $row['allday'];
$arre[$cnt]['url'] = $row['url'];
$cnt++;
}
$year = date('Y');
$month = date('m');
echo json_encode(array(
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
array(
'id' => 222,
'title' => "Event2",
'start' => "$year-$month-20",
'end' => "$year-$month-22",
'url' => "http://yahoo.com/"
)
));
?>
脚本底部的 json_encode 是一个示例。我需要获取 $arre 和 json_encode 中的数据。json_encode 的格式需要保持几乎完全相同,否则程序可能会觉得它不好吃,我的程序将无法运行。有谁知道正确的代码技术在这里是什么样的?
谢谢你!