Jump to content

html to BBCode


dedart

Recommended Posts

Hi, I have a script where I am converting html back to BBCODE for editing and I am having trouble with certain parts of the script

[code]$patterns = array ( "|\<b\>(.*?)\</b\>|s",
                    "|\<i\>(.*?)\</i\>|s",
                    "|\<u\>(.*?)\</u\>|s",
                    "|\<strike\>(.*?)\</strike\>|s",
                    "|\<div style=\"font-size: 14px; color=:#E1B500;\"\>\<b\>QUOTE:\</b\>\</font\>\<div style=\"border: 1px; border-style: solid; background-color: #FFF0B3;\"\>(.*?)\</div\>\</div\>|s");

$replacements = array ( "[ B]\$1[ /B]",
                        "[ I]\$1[ /I]",
                        "[ U]\$1[ /U]",
                        "[ STRIKE]\$1[ /STRIKE]",
                        "[ QUOTE]\$1[ /QUOTE]");[/code]

If I have a html string like: <div style="font-size: 14px; color=:#E1B500;"><b>QUOTE:</b></font><div style="border: 1px; border-style: solid; background-color: #FFF0B3;">SOME TEXT</div></div>

The page will output: [ B]QUOTE:[ /B]
SOME TEXT

I have tried re-arranging the arrays and even adding the bbcode bolds to the html string but nothing seems to be working
CAN SOMEONE PLEASE HELP ME, IT'S DRIVING ME CRAZY

dedart
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.