PHP Elseif Ternary Operators
<p>I am trying to convert the following code into a Ternary Operator, but it is not working and I am unsure why. I think my problem is that I do not know how to express the <code>elseif</code> operation in ternary format. From my understanding and <code>elseif</code> is performed the same way as an <code>if</code> operation by using the format <code>: (condition) ? 'result'</code>. </p>

<pre><code>if ($i == 0) {
    $top = '&lt;div class="active item"&gt;';
} elseif ($i % 5 == 0) {
    $top = '&lt;div class="item"&gt;';
} else {
    $top = '';
}

$top = ($i == 0) ? '&lt;div class="active item"&gt;' : ($i % 5 == 0) ? '&lt;div class="item"&gt;' : '';
</code></pre>
