user796443
user796443

Reputation:

php if statement with continue works the other way around as I would expect

So I've timestamps:

  1. Start: 1353441600 Cutoff: 1353736800 (start < cutoff)
  2. Start: 1353790800 Cutoff: 1353736800 (start > cutoff)

I have php statement:

if ($eventStarted < $todaysCutoff) continue;

I would expect this statement to show 1 but instead it shows 2. Is this correct, and I'm not understanding something? It acts like break to me now.

<?php
if (tribe_is_day()) {
        $eventStarted = strtotime(tribe_get_start_date(null, false, 'Y-m-d H:i:s'));
        $eventEnded = strtotime(tribe_get_end_date(null, false, 'Y-m-d H:i:s'));
        $todaysCutoff = strtotime($current_url_date . ' 06:00:00');

            echo ' Start: ' . $eventStarted . ' Cutoff: ' . $todaysCutoff . ' End: ' . $eventEnded;

        if ($eventStarted < $todaysCutoff) continue;
} ?>

I'm stupid :)

Upvotes: 1

Views: 18393

Answers (1)

Gung Foo
Gung Foo

Reputation: 13558

the continue keyword is used inside loops like for or while. Either your code does not include the loop or you are "doing it wrong (TM)". :)

http://php.net/manual/en/control-structures.continue.php

Upvotes: 3

Related Questions