The code below is supposed to take anything between [SOMEBBCODE] and [/SOMEBBCODE] and put it in $var, for some reason it returns ($var) Woo Text Some Text! I am not sure why it is doing that, also I found out when I put | around the \1 that it is not returning the extra text (Some Text!) but thats just stuck on the end. Can anyone help me figure out why it is doing that? I even tried taking it out a second time ($var2) but that didnt work. Again it just sticks it on the end.
<?php
$wrapper = "Some Text [SOMEBBCODE] Woo Text [/SOMEBBCODE] Some more Text!";
echo "$wrapper<BR><BR><BR><BR>";
$var = preg_replace("#(.*?)\\[SOMEBBCODE\\](.*?)\\[/SOMEBBCODE\\]#si", "|\\2|", $wrapper);
$var2 = preg_replace("#\|(.*?)\|(.*?)#si", "|\\1|", $var);
echo "$var<BR><BR><BR><BR>";
echo "$var2<BR><BR><BR><BR>";
?>