Announcement

Collapse
No announcement yet.

small hint regarding cleaner.php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • small hint regarding cleaner.php

    Hello,

    after the import (with which Marco van H. has helped us out superbly!! thumbs up mate )

    I was cleaning up some of the code pieces from the old board layout.

    Unfortunately there was a sneaky thing in there, some of the strings I want to replace have the " character in them.

    example; I would like to replace all instances of <font color="0000ff"> with the appropriate vB code.

    fill this in in the array in cleaner.php: (line 51 and further)

    Code:
    $replacer = array(
       "<font color="0000ff">" => "[COLOR=blue]",
    due to the ", the first part of the array becomes: "<font color="

    and afterwards there is another unexpected ".

    result:

    Parse error: syntax error, unexpected T_LNUMBER, expecting ')' in /var/xirictrl/hosted/www/volvo300club/volvo300club.nl/forum/impex/tools/cleaner.php on line 51


    After some experimenting I figured php has a way to distinguish between 'code " ' and 'text " '

    I tried the following array as well:

    Code:
     "<font color=/"0000ff/">" => "[COLOR=blue]",
    but that didn't work.

    consulted PHP manual, finally found out that i was using the wrong slash.

    so... this is what worked for me:

    Code:
     "<font color=\"0000ff\">" => "[COLOR=blue]",
    so, the hint is, if you have to replace " s in your text, include a trailing backslash \ to tell php its not the end of the code piece.

  • #2
    You would need to either escape the embedded quotes (with a backslash \), or use single quotes around the string:

    PHP Code:
     '<font color="0000ff">' => "[color=blue]"
    Want to take your board beyond the standard vBulletin features?
    Visit the official Member to Member support site for vBulletin Modifications: www.vbulletin.org

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X