...

View Full Version : Php str_replace



Andy92
02-25-2007, 08:00 PM
Hi there,

I have a comments system, where people can post comments. I have disabled html and the <> tags, so i am making my own bord code. At the moment, people can add images by putting in image url here. This is the code i have that lets people do this...



$imgtag = array("", "");
$replacetag = array("<img src='","' id='usr'>");
$newcomment = str_replace($imgtag, $replacetag, $row2[comments]);

$postedcomment = wordwrap($newcomment,83, " ", 1);

echo"$postedcomment";
My question is, i want to add in another tag so that people can make their text bold by putting........This text will be bold without the 1 in the tag - (I have put the 1 in the b tag because if i dont, then this forum board code will acctually make the text bold because that is the tag that they use).

This is the code i have so far...



$boldtag = array("", "");
$replacetagbold = array("<b>","</b>");
$newcomment2 = str_replace($boldtag, $replacetagbold, $row2[comments]);
Now, i have tried so many ways to link it up with the other code, like merge them together, but everything i have tried fails. How can i merge the bold replace with the img replace so that people can use both [img] and [b] tags???

:confused:

Mhtml
02-25-2007, 10:15 PM
Use regular expressions. Search the forums, there have been lots of posts regarding this exact topic.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum