[Edited with "noparse" tags so code would display correctly -- NogDog]
Hello all,
I'm working on a simple thing to change BBcode to html code, for the URL bbcode. It's coming from a form where, in this instance, the input is $text. When I put this in, however, it gives me nothing in return. I don't honestly know where I've gone wrong, other than the fact that i haven't written in a loop yet.
[noparse]
<?php
$text = "blahblah[url=HYPERLINK]LINKTEXT[/url]blahblah[url=HYPERLINK]LINKTEXT[/url]blahblahblah";
function hyperlinks($text)
{
$startofstring = substr($text, 0, strpos($text, "[url"));
$endofstring = strstr ($text, "[/url]");
$endofstring = str_replace("[/url]", "", $endofstring );
$newstring = strstr ($text, "[url=");
$newstring = substr($newstring, 0, strpos($newstring, "[/url]"));
$newstring = $newstring . "</a>";
$newstring = str_replace("[url=", "<a href='", $newstring );
$newstring = str_replace("]", "' target='_blank'>", $newstring );
$new = $startofstring . $newstring . $endofstring;
}
if(strstr($text,"[url=")) {
$text = hyperlinks($text);
} else {
echo $text;
}
?>
[/noparse]
Any help would be greatly appreciated!
Thanks,
-Jon "Cheez" Roost