tags:

views:

115

answers:

6

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 { echo '<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 { echo '<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://...&lt;/li&gt;
Title3<br/>http://...&lt;/li&gt; <!-- this ain't right, it should start with <li> -->
Title4<br/>http://...&lt;/li&gt; <!-- same here -->
</ol>
</ol>

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

+3  A: 

You forgot echo inside the else statement.

Savageman
+4  A: 
  } else { '<li value="' . $key2 . '">';}
//--------^

You missed an echo.

KennyTM
You get the check because of the illustration.
Arlen Beiler
+2  A: 

You're not echoing the else statement; it is just being uttered, it is not being output.

fbrereto
+2  A: 

You're missing an echo in the else clause.

kemp
+2  A: 

You're missing an 'echo' in your else statement. Try adding that in and see what output you get.

Sean
+1  A: 

You say you've updated the code and its still giving you an error, but its still missing an echo

} else { '<li value="' . $key2 . '">';}
         ^
Rob
Thanks, I did fix it though in my webpage. ;-)
Arlen Beiler