I have this PHP array ($savedRequestDates) of dates:
Array ( [0] => 2018-03-29 10:56:31 [1] => 2018-03-29 10:58:09 [2] => 2018-04-12 11:28:41 [3] => 2018-04-12 13:07:25 [4] => 2018-05-09 13:08:07 )
At the bottom of the same .php page I have this:
<script type="text/javascript">
var sessions = new Array('<?php echo json_encode($savedRequestDates); ?>');
console.log(sessions[0]);
</script>
The console.log(sessions[0]); returns:
["2018-03-29 10:56:31","2018-03-29 10:58:09","2018-04-12 11:28:41","2018-04-12 13:07:25","2018-05-09 13:08:07"]
Why is the JavaScript array flattening at the 0 index? If I try console.log(sessions); it returns an array with one variable, not 5, as the php array clearly shows.
Am I missing something here?