dadamssg Posted August 7, 2009 Share Posted August 7, 2009 how do i make this, which works $regex = "#([\[]b[\]])(.*)([\[/]/b[\]])#e"; $output = preg_replace($regex, "('<b>$2</b>')", $reply); into a function like this?...which doesn't work function forumtags($text) { $find = array ( '#([\[]b[\]])(.*)([\[/]/b[\]])#e', ); $replace = array ( '<b>$2</b>', ); return preg_replace($find, $replace, $text); } i get this error Parse error: syntax error, unexpected '<' in /home/inaggie1/public_html/main/showthreadf.php(23) : regexp code on line 1 Fatal error: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Failed evaluating code: <b> bold</b> in /home/inaggie1/public_html/main/showthreadf.php on line 23 Quote Link to comment https://forums.phpfreaks.com/topic/169170-solved-help-with-making-simple-regex-function/ Share on other sites More sharing options...
.josh Posted August 7, 2009 Share Posted August 7, 2009 remove the 'e' after the # in your pattern. Quote Link to comment https://forums.phpfreaks.com/topic/169170-solved-help-with-making-simple-regex-function/#findComment-892616 Share on other sites More sharing options...
dadamssg Posted August 7, 2009 Author Share Posted August 7, 2009 i love you Quote Link to comment https://forums.phpfreaks.com/topic/169170-solved-help-with-making-simple-regex-function/#findComment-892619 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.