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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.