dustinnoe Posted February 23, 2007 Share Posted February 23, 2007 Anyone know where I can get the sytax highlighting that this forum offers in Code blocks? I want to be able to display colored code in articles on my website. <?php echo "I want these code blocks on my website"; ?> Thanks Link to comment https://forums.phpfreaks.com/topic/39738-code-block/ Share on other sites More sharing options...
coldkill Posted February 23, 2007 Share Posted February 23, 2007 Try using Preg_replace finding quote marks etc and adding the HTML tags around them for colour. Ie <?PHP $subject 'echo "This is a test echo";'; $code[0] = "|\"(.*?)\"|s"; $code_replace[0] = "<font color=\"#ff4400\">\"$1\"</font>"; $replaced = preg_replace( $code, $code_replace, $subject ); ?> You'd have to populate the $code array with all the keywords and function names and the $code_replace array with the HTML you want them surrounded it. Cold Link to comment https://forums.phpfreaks.com/topic/39738-code-block/#findComment-191861 Share on other sites More sharing options...
dustinnoe Posted February 23, 2007 Author Share Posted February 23, 2007 There has to be a class out there somewhere that already does everything. I am looking to just feed it a string and get is back formated. Link to comment https://forums.phpfreaks.com/topic/39738-code-block/#findComment-191864 Share on other sites More sharing options...
JasonLewis Posted February 23, 2007 Share Posted February 23, 2007 i think this question has been asked and answered in this board somewhere. and i believe the actual function your looking for is this: http://au2.php.net/highlight_string Link to comment https://forums.phpfreaks.com/topic/39738-code-block/#findComment-191996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.