WordPress php loop over CPT comparing values to previous item in array -


i query orders , loop on them 1 bye 1 , print looks like: (only copied 1 order) 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 goal check start , end hours of every attractie in order see if there attracties overlapping each other order can have multiple attracties.

so here's i've tried 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 $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;  } 


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -