Author Topic: preg_replace Problem  (Read 4934 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.807
  • I ♥ 4I
    • View Profile
preg_replace Problem
« on: September 11, 2010, 02:07:40 AM »
Did I done a different code found!


the building for me is:
$search_array = array(
$replace_array = array(
"<ol type=\"\\5\">\\7</ol>",
"<a href=\"http://www.\\6\" target=\"_blank\" rel=\"nofollow\">\\8</a>",
"<a href=\"\\5\" target=\"_blank\" rel=\"nofollow\">\\7</a>",
"<a href=\"http://www.\\5\" target=\"_blank\" rel=\"nofollow\">www.\\5</a>",
"<a href=\"\\4\" target=\"_blank\" rel=\"nofollow\">\\4</a>",
"<pre>Code:<hr size=1>\\5<hr size=1></pre>",
"java script:",
"about :",
"<img src=\"./board/wcf/images/smilies/biggrin.png\" alt=\":D\">",
"<img src=\"./board/wcf/images/smilies/smile.png\" alt=\":)\">",
"<img src=\"./board/wcf/images/smilies/sad.png\" alt=\":)\">"
$text preg_replace($search_array$replace_array$text);
    if (!
$bbcode_img)  {
$text preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU""<a href=\"\\5\" target=\"_blank\">\\5</a>"$text);
    else  {
$text preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU""<img src=\"\\5\">"$text);
$text preg_replace("/(\[)(b)(])(\r\n)*([^\"]*)(\[\/b\])/siU""<b>\\5</b>"$text);

It's about this smiley ""/:(/si"," and "/(\8)\)/si",
I do not get converted, I have tried all variations ... someone knows more?
« Last Edit: September 11, 2010, 02:29:51 AM by Benny »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: preg_replace Problem
« Reply #1 on: September 11, 2010, 04:47:32 AM »
You must escape parenthesis:
Code: [Select]
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)