I'm trying to fill a javascript array from a php multidimensional array.
I've used the following code to convert the php array to a javascript array:
var bookings = <?php echo json_encode( $bookeddates ) ?>;
The code that's working:
var unavailableDates = [
{start: bookings[0][1], end: bookings[0][2]},
{start: bookings[1][1], end: bookings[1][2]},
];
The code that's not working:
var unavailableDates = [
for (var i = 0; i < bookings.length; i++) {
{start: bookings[i][1], end: bookings[i][2]},
}
];
The solution is very simple I guess but I'm struggling with this problem for days already. what am I doing wrong?