You almost have it correct, you can put PHP tags inside
<script>
elements! You've already formatted the dates into the
$start_datum
and
$eind_datum
variables so you just need to print them out at the correct spot:
var dates = ["<?php echo $start_datum; ?>", "<?php echo $eind_datum; ?>", "30-07-2022"];
Remember that PHP will pre-process the whole document so there's no limitation to where you can put the PHP tags. You may, however, want to consider moving the
foreach()
part though as it
could potentially print out more than one
</head><body>
for the page which could break it. Try to keep any loops within certain boundaries:
<html>
<head>
<!-- Fine to loop here -->
</head>
<body>
<!-- Fine to loop here -->
</body>
</html>