Jump to content

Formatting Code with preg_replace


ChadNomad

Recommended Posts

I've been using this to highlight PHP code:

 

$newcontent = preg_replace('/\[command\](.*?)\[\/command\]/ie', 'highlight_string(\'$1\', TRUE)', nl2br($page_information[content]));

 

The only problem is it doesn't work on content that has multiple lines. Confused...

 

Also, another question, how would I wrap a html div block around the highlight_string function?

 

Any help appreciated.

Link to comment
https://forums.phpfreaks.com/topic/108074-formatting-code-with-preg_replace/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.