Answer the question
In order to leave comments, you need to log in
How to split an array of dates into groups by week?
I have an array of dates
$array = [0 = > ['date' => unixDate, 'param' => 'val'], ..]
$res = ['week1' => [], ..]
Answer the question
In order to leave comments, you need to log in
function splitByWeek($dots) {
$splitted = [];
foreach ($dots as $dot) {
$week = date("YW", $dot['date']);
$splitted[$week][] = $dot;
}
return $splitted;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question