为json格式化数组

etm*_*124 0 php

我正在使用FullCalendar jquery插件在我的网站上显示日历.我能够对我的日历上显示的任何值进行硬编码.格式应为:

echo json_encode(array(

        array(
            'id' => 1136,
            'title' => "Understanding Health-Care Regulations (Part II) and COBRA Compliance Strategies",
            'start' => "2011-11-17",
            'url' => "/www/conferences/conference.php?ID=1136"
        ),

        array(
            'id' => 1154,
            'title' => "Making the Most of your Membership",
            'allDay' => false,
            'start' => "Wed, 18 Nov 2011 11:00:00 EST",
            'url' => "/www/conferences/conference.php?ID=1154"
        ),
        array(
            'id' => 1137,
            'title' => "2011 Annual Human Resources Conference",
            'start' => "2011-11-29",
            'url' => "/www/conferences/conference.php?ID=1137"
        ),


    ));
Run Code Online (Sandbox Code Playgroud)

当试图模仿这个数组结构时,我正在使用它:

$conferences = dbStoredProc('cp_meeting_get_list_new');
$events = array();

foreach ($conferences as $c){
    $push = array(
        'id'        => $c['ID'],
        'title'     => $c['name'],
        'start'     => date("Y", $c['epochDate']) . "-" . date("M", $c['epochDate']) . "-" . date("d", $c['epochDate']),
        'url'       => '/events/details.php?id' . $c['ID'],
    );
    array_push($push, $events);
}
echo json_encode($events);
Run Code Online (Sandbox Code Playgroud)

当我回应我的$events变量时,我得到了[].

有任何想法吗?

xda*_*azz 6

array_push($push, $events);
Run Code Online (Sandbox Code Playgroud)

应该

array_push($events, $push);
Run Code Online (Sandbox Code Playgroud)

要不就

$events[] = $push;
Run Code Online (Sandbox Code Playgroud)