Having trouble with str_replace
Quote:
function prepared($post){
$bbopen = array("[!b]", "[!i]", "[!u]", "[!hr]", "[!quote]", "[!code]";
$bbclose = array("[!/b]", "[!/i]", "[!/u]", "[!/quote]", "[!/code]");
$mlopen = array("<b>", "<i>", "<u>", "<hr/>", '<b>Quote:</b><p style="border:solid; border-color:#0000FF">', '<b>Code:</b><p style="border:solid; border-color:#ABABAB">');
$mlclose = array("</b>", "</i>", "</u>", "</p>", "</p>"); # open tags
str_replace($bbopen, $mlopen, $post);
# close tags
str_replace($bbclose, $mlclose, $post);
str_replace("\n", "<br>", $post);
str_replace("\r", "<br>", $post);
str_replace("<", "<", $post);
str_replace(">", ">", $post);
return $post;
}
I wrote my own forum for something to do to pass the time but I can't get the above to do anything, meaning people could use html and javascript potentially if they realised. But it doesn't seem to change the string I pass to it. Any help would be appreciated.
Note the ! was to stop this forums bb-code working on them.
Re: Having trouble with str_replace
you need to set the replaced text to a varible, not just call the function
PHP Code:
$post = str_replace(">", ">", $post);