Displaying code with <pre> tags.

Posted by iMaster on Stack Overflow See other posts from Stack Overflow or by iMaster
Published on 2010-04-26T21:37:19Z Indexed on 2010/04/26 21:43 UTC
Read the original article Hit count: 195

Filed under:
|
|

Currently I'm using

<pre><code> code here </code><pre>

to display code. I'm pulling this information from a DB for a blog. The problem I'm having is that some of the code isn't showing. For example, in the source code I have this:

<pre><code><br />
echo '<ul class="mylist"><li><ul class="left">';
foreach($nameArray as $name) {
    if($countervar == $half) {
        echo '</ul></li>';
        echo'<li><ul class="right">';
    }
    echo '<li>$name</li>';
    ++$i;
}
echo '</ul></li>';    
echo '</ul>';
?>

But all that shows up is this:

echo '';
foreach($nameArray as $name) {
if($countervar == $half) {
echo '';
echo'';
}
echo '$name';
++$i;
}
echo '

An there's some really weird formatting/spacing issues as well. Any ideas as to what is causing this? I should also mention that some of the other sets of code show up just fine.

© Stack Overflow or respective owner

Related posts about html

Related posts about php