PDA

View Full Version : BBCode Problem



Moh
17-09-2008, 02:36 PM
Well, this is reverse BBCode :P

For my reverse BBCode code, I have the following:


function reversebb($string)
{
$bbcode = array('\\1',
'\\1',
'\\1',
'\\2',
':heart:',
':diamond:',
':club:',
':spade:',
':tm:',
'(l)',
'\\1',);

$replace = array("'<b>(.*?)</b>'",
"'<strike>(.*?)</strike>'",
"'<u>(.*?)</u>'",
"'<font color=\"(.*?)\">(.*?)</font>'",
"'&hearts;'",
"'&diams;'",
"'&clubs;'",
"'&spades;'",
"'&trade;'",
"'<img src=\"images/(l).gif\">'",
"'<i>(.*?)</i>'",);

$string = preg_replace($replace, $bbcode, $string);

$string = str_replace("\n", "", $string);

$string = str_replace("<br />\n", "\n", $string);

$string = str_replace("<br />", "", $string);

return $string;

}


But, If $string is "<img src="images/(l).gif">", it dosn't display "(l)", it just displays "<img src="images/(l).gif">".

Can anyone see whats wrong?

Dentafrice
17-09-2008, 02:43 PM
Yeah what the hell are you trying to do?

(l)? As the BBcode? It's trying to match (l) and replace it into <img src="images/(l)">

What exactly do you want it to do?

For one you are not defining a variable in the search, nor the replace.

Moh
17-09-2008, 03:13 PM
Yeah what the hell are you trying to do?

(l)? As the BBcode? It's trying to match (l) and replace it into <img src="images/(l)">

What exactly do you want it to do?

For one you are not defining a variable in the search, nor the replace.
Well, if your message is "Hey There (l)" it will insert it into the database like "Hey There <img src="images/(l).gif">".

But for you to edit your comment, I want it to display as (l) again.

All the other reversebb works such as [color] etc.. just not this one :S

So its reversing BBCode.

Dentafrice
17-09-2008, 03:32 PM
try this



'<img src=\"images/(l).gif\">'
instead of "'<img src=\"images/(l).gif\">'"

Moh
17-09-2008, 03:38 PM
try this



'<img src=\"images/(l).gif\">'
instead of "'<img src=\"images/(l).gif\">'"
Nope :(

Calon
17-09-2008, 03:41 PM
This may be a stupid question to ask, but what is l.gif?

Also, make sure that your editor isn't changing the brackets to the special character code

Dentafrice
17-09-2008, 03:42 PM
is it being stored on the server with slashes, etc?

Moh
17-09-2008, 04:08 PM
This may be a stupid question to ask, but what is l.gif?

Also, make sure that your editor isn't changing the brackets to the special character code
on msn type in (l)

is it being stored on the server with slashes, etc?
That was the second thing I checked xD

In the database, its storing it as <img src="images/(l).gif">

Agnostic Bear
17-09-2008, 04:19 PM
"'<img src=\"images/(l).gif\">'"try this:


'#<img src="images/(l).gif">#i',
But no " ".

Alternatively just parse bbcode on display, much easier.

Want to hide these adverts? Register an account for free!