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 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. 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 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
Archived
This topic is now archived and is closed to further replies.