I am using fullcalendar (JSON) and want to use a foreach loop in a multidimensional array. What I've got is this:
echo json_encode(array(
array(
'id' => 111,
'title' => $arr['new'][0] . ' new',
'start' => $arr['booking_date'][0],
'url' => "bookings/new/1",
'color' => '#F7F8E0',
'textColor' => 'black'
),
array(
'id' => 111,
'title' => $arr['completed'][0] . ' completed',
'start' => $arr['booking_date'][0],
'url' => "bookings/completed/1",
'color' => '#D8D8D8',
'textColor' => 'black'
),
array(
'id' => 111,
'title' => $arr['accepted'][0] . ' accepted',
'start' => $arr['booking_date'][0],
'url' => "bookings/accepted/1",
'color' => '#E0ECF8',
'textColor' => 'black'
),
));
Now I have to input every array manually, but how can I use foreach to do that for me?
I've tried something like this, but it didn't work. echo json_encode(array(
foreach($arr as $row) {
array(
'id' => 111,
'title' => $arr['new'][0] . ' new',
'start' => $arr['booking_date'][0],
'url' => "bookings/new/1",
'color' => '#F7F8E0',
'textColor' => 'black'
),
}