如何使用DateTime将两个日期之间的日期转换为数组

What i'm trying to do here is to get dates with specific criteria from 3 months range, and put them into arrays.

to get dates:

$begin = new DateTime( 'NOW' );
$end = new DateTime('NOW');
$end->modify('+6 month');

$interval = new DateInterval('P1D');
$period = new DatePeriod($begin, $interval ,$end);

filters to get my dates of criteria:

foreach ( $period as $dt ){
    if ((!($dt->format("l") === 'Saturday') || ($dt->format("l") === 'Sunday')) && ($dt->format("d") == '14')){
        $meeting = $dt->format( "Y-m-d" );
        echo $dt->format( "Y-m-d" ) . '<br />';

    }

    if((($dt->format("l") === 'Saturday') || ($dt->format("l") === 'Sunday')) && ($dt->format("d") == '14')){
        $dt->modify('Next monday');
        echo $dt->format( "Y-m-d" ) . '<br />';

    }   
}

echo '<hr>';
$interval_2 = new DateInterval('P1M');
$period_2 = new DatePeriod($begin, $interval_2 ,$end);

foreach ( $period_2 as $dt ){
    $dt->modify('last day of this month');  
    //echo $dt->format( "l Y-m-d
" ) . '<br />';
    if(($dt->format("l") === 'Saturday') || ($dt->format("l") === 'Sunday') || ($dt->format("l") === 'Friday')){
        $dt->modify('previous Thursday');
        echo $dt->format( "Y-m-d" ) . '<br />';
    } else {
        echo $dt->format( "Y-m-d" ) . '<br />';
    }


}

well all this works perfect, but they are just displaying, and i want to put them in array to get them into CSV file with fputcsv so i need them like:

Month, first_date, second_date

how can i achieve that?

resolved my issue by declaring:

$meet = array();
$test = array();

and after that in each if:

$meet[] = $dt->format( "Y-m-d" );
$test[] = $dt->format( "Y-m-d" );

and this way if you make a var_dump, it will have an array for each one of them.