I have user entered code.... and I want to replace [u] and [\u] with <u> and <\u> , respectively.
I set up an array of search strings and replacy strings.
$SEARCH_ARR = array("'[b]'","'[/b]'","'[i]'","'[/i]'","'[u]'","'[/u]'","'[p]'","'[/p]'");
$REPLACE_ARR = array("<b>","</b>","<i>","</i>","<u>","</u>","<p>","</p>");
then when i wanted to output code, i used the following:
echo preg_replace($SEARCH_ARR, $REPLACE_ARR, "[u]Hi[/u]");
When i ran the page, all i got was:
[<<
u>>]H<<<
u>i>>[<<<
u>i>b><<
u>>]
I was hoping to get: Hi (just like phpbuilder has it set up)
Anyone know what I did wrong? Or a better approach than preg_replace? Thanks much!