How to set this cases depends on if rule
<p>if i've the following</p>

<pre><code>$x = "go";
$y = "went";
$z "gone";
</code></pre>

<p>and i need to set title where title will be </p>

<pre><code>$title = $x;              //only if "y" empty no care about "z" if empty or not
$title = $x . " - " . $y; // if "y" not empty and "z" is empty
$title = $y . " - " . $z; // if "z" not empty and "y" not empty
</code></pre>

<p>this is my try but field and/or looks so permeative (i'm noob)</p>

<pre><code>$empty = ""; // i've creaty empty example
$x = "go";
$y = "went";
$z "gone";

if ($y==$empty) {
$title = $x; // output should be go

} else if($y!=$empty &amp;&amp; $z==$empty) {
$title = $x . " - " . $y;  // output should be go - went

} else if($y!=$empty &amp;&amp; $z!=$empty) {
$title = $y . " - " . $z;  // output should be went - gone

} else {
$title = $x;  // output should be go
}
</code></pre>

<p>do anyone have better suggestion ! thanks a lot</p>
