Skip to content

Instantly share code, notes, and snippets.

@dmongeau
Created April 4, 2013 23:13
Show Gist options
  • Save dmongeau/5315209 to your computer and use it in GitHub Desktop.
Save dmongeau/5315209 to your computer and use it in GitHub Desktop.
<?php
$eventsRebuilded = array();
foreach($events as $event) {
foreach($event->dates as $date) {
$datestart = date('Y-m-d',strtotime($date->datestart));
if(!isset($eventsRebuilded[$date->datestart])) {
$eventsRebuilded[$date->datestart] = array();
}
}
}
foreach($eventsRebuilded as $dateKey => $value) {
$time = strtotime($dateKey);
foreach($events as $event) {
foreach($event->dates as $date) {
if($time >= strtotime($date->datestart) && $time <= strtotime($date->dateend)) {
$eventsRebuilded[$dateKey][] = $event;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment