I query all my orders and loop over them 1 bye 1 and this is what the print looks like: (only copied 1 order) This is the dump of 1 $order
Array
(
[0] => Array
(
[attractie] => WP_Post Object
(
[ID] => 41
[post_author] => 1
[post_date] => 2016-02-29 14:30:33
[post_date_gmt] => 2016-02-29 14:30:33
[post_content] => Content
[post_title] => Title
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => post-name
[to_ping] =>
[pinged] =>
[post_content_filtered] =>
[post_parent] => 0
[menu_order] => 0
[post_type] => attracties
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
[start] => 0930
[end] => 1200
[personen] => 8
)
)
Now my goal is to check the start
and end
hours of every attractie
in an order to see if there are attracties overlapping each other an order can have multiple attracties
.
So here's what I've tried but I always get the result no overlap
.
if ( $orders->have_posts() ){
while ($orders->have_posts()) : $orders->the_post();
$order = get_field('field_56e6a0f52ce6b');
$prevEnd = null;
$found_overlap = false;
foreach($order as $o){
$attractie = $o['attractie']->post_title;
$start = $o['start'];
$end = $o['end'];
if($prevEnd !== null && $start < $prevEnd){
$found_overlap = true;
}
if ($found_overlap) {
echo "overlap\n";
} else {
echo "no overlap\n";
}
$prevEnd = $end;
}
endwhile;
}