On Mon, 6 Oct 2003 10:06:44 +0100, you wrote:

>I have on my site a part where users' can submit articles and no doubt their
>articles will contain code. Code is wrapped inside of [code] tags, i.e.
>[code]<?php echo "hi"; ?>[/code]
>
>However, there is other text in the same article, so I need to format the
>code inside of the [code] and [/code] tags using htmlspecialchars, nl2br and
>highlight_file and the rest of the code needs to be formatted with nl2br,
>strip_tags and possibly stripslashes/wordwrap.

I'd suggest using string-handling functions (explode, split, preg_split,
etc) to chop the incoming text into seperate code and text blocks.

Then use highlight_string() (not highlight_file()) on the code blocks.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to