Jump to content

[SOLVED] help with making simple regex function


dadamssg

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.