hey, im just adding some things to my little site and im getting a weird result, i havent really used ereg too much before so i need a little help.. this is what my code looks like:
//look for and change any < or > tags to their html code equivalent
$content = $news_content;
$content = ereg_replace('<', '<', $content);
$content = ereg_replace('>', '>', $content);
//look for accepted bbcode and change to html equivalent
if(ereg('[ b]', $content))
{
$content = ereg_replace('[ b]', '<b>', $content);
if(ereg('[ /b]', $content))
{
$content = ereg_replace('[ /b]', '</b>', $content);
}
else { $content . "</b>"; }
}
basically, I'm trying to have the ppl who do articles use bbcode, and then have this script change it to html code when they submit it.
The result i get when i put
[ b]hopefully[ /b] this will [ b]defina[/ b]ly work!
is
[<>]hopefully[<>] this will [<>]defina[<>]ly work!
and when i check the entry with the editing page it shows up as..
[<</b>>]hopefully[</b><</b>>] this will [<</b>>]defina[</b><</b>>]ly work!
can someone help me?
obviously its replacing all the [ b] with </b>'s but why??
and no, in my code i dont have [ b] but, i had to put the space in so the board didnt think i was trying to make something bold 😉