So for 2008-31-1 till 2008-2-2 they would be charged x for the August 31, and y for the other days in September.
So far I am using a function to output all months between the two dates. For the example used, I would get 1,2,2.
Then I tried to use array_count_values to find out how many times each month showed up.
BUT, it is not working the way it should... Here is that part of the code so far:
Code: Select all
/////// date duer
function getAllDays($start, $end, $aslist = true) {
$start = strtotime($start);
$end = strtotime($end);
$whichway = ($start < $end) ? "tomorrow" : "yesterday";
$curday = $start;
$days = array();
$days[] = date("m", $curday);
while ($curday != $end) {
$curday = strtotime($whichway, $curday);
$days[] = date("m", $curday);
}
if ($aslist === false) return $days;
$daylist = "";
foreach ($days as $day) {
$daylist .= $day.", ";
}
$daylist = substr($daylist, 0, -2);
return $daylist;
}
print_r(array_count_values(array(getAllDays("2005-01-01", "2005-01-24"))));
I hope I am not asking for too much here. I just need a direction to go in or maybe I am doing something stupid?? ...
Please Help!