Neither if nor else will run

Posted by Arlen Beiler on Stack Overflow See other posts from Stack Overflow or by Arlen Beiler
Published on 2010-04-23T16:06:12Z Indexed on 2010/04/23 16:13 UTC
Read the original article Hit count: 324

Filed under:

I don't know what the problem is.

This is the code that is the problem:

$thisvb = (int) $key2;
if ($thisvb == ($lastvb + 1)) { //This don't work
    echo '<li>';
} else { '<li value="' . $key2 . '">';}
$last = (int) $key2;

Below is the full code.

<?php
$voiceboxes = array(
    '141133'    => array(
        '1'     => array(
            'Title' => 'Title2',
            'Link'  => 'http://...',
        ),
        '2' => array(
            'Title' => 'Title3',
            'Link'  => 'http://...',
        ),
        '3' => array(
            'Title' => 'Title4',
            'Link'  => 'http://...',
        )
    )
);
$last = 0;
//$this = 0;
echo "<ol>\n";
foreach ($voiceboxes as $key => $value) {
    $lastvb = 0;
    $thisvb = 0;
    //$voiceboxes[$key]['title']
    echo "<ol>\n";
    foreach ($value as $key2 => $value2) {
            $thisvb = (int) $key2;
            if ($thisvb == ($lastvb + 1)) { //This don't work
                echo '<li>';
            } else { '<li value="' . $key2 . '">';}
            $last = (int) $key2;
            echo $voiceboxes[$key][$key2]['Title'] . "<br/>" . $voiceboxes[$key][$key2]['Link'] . '</li>' . "\n";
            }
        }
    echo "</ol>\n";
    echo '</ol>';
?>

This is what I get

<ol>
<ol>
<li>Title2<br/>http://...</li>
Title3<br/>http://...</li> <!-- this ain't right, it should start with <li> -->
Title4<br/>http://...</li> <!-- same here -->
</ol>
</ol>

I can't figure it out, does anyone know?

© Stack Overflow or respective owner

Related posts about php