功能打印但不能处理数组

We are having troubles trying to insert multiple values generated from a function into an array. When we print the function using a string and we copy the results manually it works but when we try to make it work using the string into an array it doesn't.

<?php 

function dateRange( $first, $last, $step = '+1 day', $format = 'm/d/Y' ) {

$current = strtotime( $first );
$last = strtotime( $last );

while( $current <= $last ) {

    $dates .= "'" . date( $format, $current) . "', ";
    $current = strtotime( $step, $current );
}

return $dates;
} 

$all_dates = dateRange( '01/20/1999', '01/23/1999'); 

echo $all_dates; /* PRINTS ALL DATES BETWEEN TWO DATES: '01/20/1999', '01/21/1999', '01/22/1999', '01/23/1999', */

query_posts( array(
'post_type' => 'bbdd',
'meta_query' => array(
    $location,
    array(
        'key' => 'date',
        'value' => array($all_dates), /*  DOESN'T WORK. INSTEAD, IF WE COPY THE RESULT OF "echo $all_dates;" MANUALLY, IT DOES WORK */
    ),
)
) );

?>

You're returning a string, not an array, in the function.

function dateRange( $first, $last, $step = '+1 day', $format = 'm/d/Y' ) {

    $current = strtotime( $first );
    $last = strtotime( $last );

    while( $current <= $last ) {

        $dates[] = date($format, $current);
        $current = strtotime($step, $current );
    }

    return $dates;
}

That will return an array.

Then, in your mysql query:

'value'   => $all_dates

Why not put it in an array in the first place:

<?php

function dateRange( $first, $last, $step = '+1 day', $format = 'm/d/Y' ) {
    $dates = array();
    $current = strtotime( $first );
    $last = strtotime( $last );

    while( $current <= $last ) {

            $dates[] = date($format, $current);
            $current = strtotime( $step, $current );
    }

    return $dates;
} 

?>