This is the error I'm getting.
Fatal Error: Allowed memory size exhausted.
I'm fetching arrays containing a date from
and a date till
. I'm trying to get all the dates in between and add them to a new array. Apparently nested loops and multi-arrays are exhausting.
I need a less exhausting way of getting all the dates.
This is my code:
$query = "SELECT *
FROM reservate
ORDER BY from";
$result = $connect->query($query);
$reservations = array();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$reservations[] = $row;
}
}
$connect->close();
//AVAILABILITY CHECK
$nonAvailable = array();
foreach($reservations as $reservation){
$from = $reservation['from'];
$till = $reservation['till'];
while($from <= $till){
$nonAvailable[] = $from;
$from = date('Y-m-d', strtotime("+1 days"));
}
}