Jump to content

[SOLVED] simple array / preg_replace question


lonewolf217

Recommended Posts

I have this bit of code that i have pieced together for a BBCode translation, but it is not liking what I am using for the color but I cannot figure out why. the error I get is this

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'c' in \viewKB.php on line 62

where line62 is the preg_replace line

function bbcode_format ($str) {
  $codeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
						<tr>
							<td class="codebody">$1</td>
						</tr>
				   </table>';


  $simple_search = array(
                          '/\[b\](.*?)\[\/b\]/is',                               
                          '/\[i\](.*?)\[\/i\]/is',                               
                          '/\[u\](.*?)\[\/u\]/is',
                          '/\[code\](.*?)\[\/code\]/is',
                          '/\[color=(.*?)\](.*?)\[/color\]/is'
                          );

  $simple_replace = array(
                          '<b>$1</b>',
                          '<i>$1</i>',
                          '<u>$1</u>',
                          $codeLayout,
                          '<font color=$1>$2</font>'
                          );

  // Do simple BBCode's
  $str = preg_replace($simple_search, $simple_replace, $str);

  return $str;
}

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.