PHP - Break out of an if statement
<p>So I have this code which assigns different variables depending on if a file exists or not:</p>

<pre><code>$progress_file_path = './data/progress.txt';

if (file_exists($progress_file_path) &amp;&amp; count($scanned) &gt; 0) {
    $scanned = file($progress_file_path);
    $last = end($scanned);
    $end = $limit + count($scanned);
}
else { 
    $last = 'unset'; 
    $end = $limit;
}
</code></pre>

<p>but I need to do more with this, I need to make sure the file has content in it. I do the check in the conditional like this:</p>

<pre><code>if (file_exists($progress_file_path) &amp;&amp; count(file($scanned)) &gt; 0)
</code></pre>

<p>because the <code>$scanned</code> variable hasn't been defined yet. So the ideal solution would be if I can break out of the if statement, and jump to the <code>else</code> part of the conditional.</p>

<p>Something like this:</p>

<pre><code>$progress_file_path = './data/progress.txt';

if (file_exists($progress_file_path)) {
    $scanned = file($progress_file_path);

    if (count($scanned) &gt; 0) { break; }

    $last = end($scanned);
    $end = $limit + count($scanned);

}I 
else { 
    $last = 'unset'; 
    $end = $limit;
}
</code></pre>

<p>but that doesn't work, you can't break or continue out of an if statement. I was thinking maybe using <code>goto</code> to jump into the <code>else</code> part of the conditional but I doubt that will work either. Is there a way to jump to the else part of a conditional like this?</p>