-3

I am trying to style my code that is being pulled out from the database. It is multi-lined code stored as a VAR-CHAR on a table "table1".

echo "<section class='styleElement'>" . htmlentities($code_display['Code']) . "</section>";

It displays the code fine, but it just places it all in a big block of text.

What I am asking is:

How do I indent each part correctly, and list all the elements so that it looks like a readable page.

The example: My page im working on

Any help would be appreciated. I have looked around, but most answers I find are more about the (htmlspecialchars / htmlentities).

I am not too bothered by colour coding the elements on the page, just the indentations, and numbering.

I am exploring the explode function at the moment, so I should now be ok.

Thanks. John

2 Answers2

0

Try out this PEAR class. It allows you to programmatically format PHP code.

Sudar
  • 18,954
  • 30
  • 85
  • 131
0

To format your output, use <pre> or nl2br().

stealthyninja
  • 10,343
  • 11
  • 51
  • 59
  • 1
    Thanks, i found the main issue with my code was that I was inputting directly into the database through the phpmyadmin page. When i inputted the code via a textarea element it registered the codes shape and format, and then put it inside
     elements to get it working. Thanks for the help. Im slowly getting their with PHP.
    – user1838313 Nov 20 '12 at 10:30