Whilst I don't understand your aversion to loops, I do understand hiding code away as much as possible.
To that end, I would extend PHP's DateTime object to give the functionality you are after. Something like this:-
class MyDateTime extends DateTime
{
/**
* Creates an array of date strings of all days between
* the current date object and $endDate
*
* @param DateTime $endDate
* @return array of date strings
*/
public function rangeOfDates(DateTime $endDate)
{
$result = array();
$interval = new DateInterval('P1D');
//Add a day as iterating over the DatePeriod
//misses the last day for some strange reason
//See here http://www.php.net/manual/en/class.dateperiod.php#102629
$endDate->add($interval);
$period = new DatePeriod($this, $interval, $endDate);
foreach($period as $day){
$result[] = $day->format('Y-m-j');
}
return $result;
}
}
Then when you want to use it, you can do this:-
$st_date = new MyDateTime("2012-07-20");
$en_date = new DateTime("2012-07-27");
$dates = $st_date->rangeOfDates($en_date);
var_dump($dates);
Will give the following output:-
array
0 => string '2012-07-20' (length=10)
1 => string '2012-07-21' (length=10)
2 => string '2012-07-22' (length=10)
3 => string '2012-07-23' (length=10)
4 => string '2012-07-24' (length=10)
5 => string '2012-07-25' (length=10)
6 => string '2012-07-26' (length=10)
7 => string '2012-07-27' (length=10)
Although, unfortunately, you will probably need a loop to iterate over that array :)
Obviously, this solution uses loops to achieve its goal, but they are encapsulated in a nice re-usable piece of code.
See the PHP manual on DateTime, DateInterval and DatePeriod for more information. There are lots of tips in the comments to those pages.