Nesting if else statements in PHP to validate a URL
<p>I'm currently writing up a function in order to validate a URL by exploding it into different parts and matching those parts with strings I've defined. This is the function I'm using so far: </p>

<pre><code>function validTnet($tnet_url) {
    $tnet_2 = "defined2";
    $tnet_3 = "defined3";
    $tnet_5 = "defined5";
    $tnet_7 = "";

    if($exp_url[2] == $tnet_2) {
        #show true, proceed to next validation

        if($exp_url[3] == $tnet_3) {
        #true, and next

                if($exp_url[5] == $tnet_5) {
                #true, and last

                        if($exp_url[7] == $tnet_7) {
                        #true, valid
                        }
                }
            }
    } else {
        echo "failed on tnet_2";
    }
}
</code></pre>

<p>For some reason I'm unable to think of the way to code (or search for the proper term) of how to break out of the if statements that are nested.</p>

<p>What I would like to do check each part of the URL, starting with <code>$tnet_2</code>, and if it fails one of the checks (<code>$tnet_2</code>, <code>$tnet_3</code>, <code>$tnet_5</code> or <code>$tnet_7</code>), output that it fails, and break out of the if statement. Is there an easy way to accomplish this using some of the code I have already?</p>
