How to accomplish this if then statement with less repetition?
<p>I have something simple I'm trying to accomplish with less repetition.</p>

<p>By default, I want a div to be shown, however if $x == 1, then check to see if $y != 1, and if $y doesn't, then don't show the block.</p>

<p>However the best I can come up with is the following:</p>

<pre><code>if($x) {

    if($y != 1) {

        echo '&lt;div&gt;display block&lt;/div&gt;';        
    }

} else {

    echo '&lt;div&gt;display block&lt;/div&gt;';

}
</code></pre>

<p>This seems a bit repetitive.</p>

<p>I know I can tweak it a bit and do something like:</p>

<pre><code>$displayBlock = '&lt;div&gt;display block&lt;/div&gt;';

if($x) {

    if($y != 1) {

        echo $displayBlock;     
    }

} else {

    echo $displayBlock;

}
</code></pre>

<p>But even still, I have a feeling that there is a way to do this whole if if else thing which I can't see right now.</p>

<p>How do you accomplish the above with less if statements? So: if $x != 1 (default), then show the displayBlock. if $x == 1, and $y != 1, then show the display block. If $x == 1 &amp;&amp; $y == 1, then do <em>not</em> show the displayBlock.</p>
