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;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.