从一个数组中的每一行获取两个日期之间的所有日期的数组

I'm trying to get an array of all dates between the 2 dates which im getting out the database for each row. for example there is 3 rows with 2017-02-02 and 2017-02-03 and a row with 2017-02-18 and 2017-02-20 I would like to get an array with the output [2017-02-02, 2017-02-03, 2017-02-18, 2017-02-19, 2017-02-20]

So far I have a query which gets all of the dates and echo's the start and end date and a script to get an array with the dates between 2 dates.

How can I make it work so it's getting all the dates of every row into one array?

<?php
    $result = mysqli_query($con, "SELECT * FROM invoice_line WHERE car_car_id = $id");
    while ($auto = mysqli_fetch_array($result)) {
    ?>
          <h2 class="title_car">
            <?php echo $auto['start_date'] . ' - ' . $auto['end_date'];?>
          </h2>
        <hr>
        <?php $dateRange = getDateRange($auto['start_date'], $auto['end_date']); ?>
    <?php } ?>

    <?php
    function getDateRange($startDate, $endDate, $format="Y-m-d")
{
    //Create output variable
    $datesArray = array();
    //Calculate number of days in the range
    $total_days = round(abs(strtotime($endDate) - strtotime($startDate)) / 86400, 0) + 1;
    //Populate array of weekdays and counts
    for($day=0; $day<$total_days; $day++)
    {
        $datesArray[] = date($format, strtotime("{$startDate} + {$day} days"));
    }
    //Return results array
    return $datesArray;
}

print_r($dateRange);
?>

You have to foreach every array to print the dates.

<?php
$result = mysqli_query($con, "SELECT * FROM invoice_line WHERE car_car_id = $id");
while ($auto = mysqli_fetch_array($result)) {?>
  <h2 class="title_car">
    <?php echo $auto['start_date'] . ' - ' . $auto['end_date'];?>
  </h2>
  <hr>
  <?php 
  $date_text = "";
  $dateRange = getDateRange($auto['start_date'], $auto['end_date']);
  if(!empty($dateRange)){
    foreach($dateRange as $dateR){
      $date_text .= $dateR.", ";
    }
  }
  echo rtrim($date_text,", ")."<br>";
}?>

Output:

2011-05-03, 2011-05-04, 2011-05-05, 2011-05-06, 2011-05-07, 2011-05-08

2011-05-20, 2011-05-21, 2011-05-22, 2011-05-23

.

.
.

You can use DatePeriod class.

Your code would something like this:

<?php
$rows = [
    [ new DateTime(), (new DateTime())->modify('+3 days') ],
    [ (new DateTime())->modify('+20 days'), (new DateTime())->modify('+30 days') ],
];

$dates = [];

foreach ($rows as $row) {
    $dateRange = new DatePeriod($row[0], new DateInterval('P1D'), $row[1]);

    foreach ($dateRange as $date) {
        $dates[] = $date;
    }
}

var_dump($dates);