fxuser Posted April 12, 2011 Share Posted April 12, 2011 So i have a custom tag like: [ code style=php ] [ /style] The user has plenty options such as c,c++,js and more, so if the user has posted some code in php and after some code in c++ i want to search the [ code] [ /code] tags to see if the style exists , and then call the highlight function .. i suppose this can be done via regex or something similar? Thanks. Link to comment https://forums.phpfreaks.com/topic/233515-highlight-style-in-code-tag/ Share on other sites More sharing options...
fxuser Posted April 13, 2011 Author Share Posted April 13, 2011 Bump* Im using this for now: $search = array( '/\[code style=(.*?)\](.*?)\[\/code\]/is' ); $replace = array( '<div class="codetext" id="$1">$2</div>' ); return preg_replace($search,$replace,$input); so if style = php and inside the code tags i have <?php echo "test"; ?> it will output <div class="codetext" id="php"><?php echo "test"; ?></div> how can i check what $1 is in order to highlight the $2 properly ? thanks, please reply for any other questions. Link to comment https://forums.phpfreaks.com/topic/233515-highlight-style-in-code-tag/#findComment-1201074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.