mattd8752 Posted February 22, 2007 Share Posted February 22, 2007 I am designing a Mini Template Engine with my site. Anyway, I've got the code: <?php function bbcode($code){ $array=array( "[b]" => "<b>", //This sets the value of [b] to <b> so if you looked under [b] in the array you would find <b>. "[/b]" => "</b>", "[i]" => "<i>", "[/i]" => "</i>", "[u]" => "<u>", "[/u]" => "</u>", "[h1]" => "<h1>", "[/h1]" => "</h1>", "[img]" => "<img src=\"", "[/img]" => "\" alt=\"\">", "[url=\"" => "<a href=\"", "\"]" => "\">", "[/url]" => "</a>", "[div class=\"" => "<div class=\"", "[/div]" => "</div>", ); $newtext = str_replace(array_keys($array), array_values($array), $code); return $newtext; } function parse($file){ $content = file($file); $type = explode("]", $content[0]); $type = explode("[", $type[0]); $type = $type[1]; $author = explode(":", $content[1]); if($author[1] == "Author"){ $disp = $author[0]; if($disp = "yes"){ $author = $author[2]; }else{ $author = "0"; } }else{ die("Error in the AUTHOR code. Please check your formatting and ensure that you use our sample template. If you continue experiencing this issue, please post on our support forums."); } $title = explode(":", $content[2]); if($title[0] == "Title"){ $title = $title[1]; }else{ die("Error in the AUTHOR code. Please check your formatting and ensure that you use our sample template. If you continue experiencing this issue, please post on our support forums."); } $size = count($content); $i=3; $main = ""; while ($i < $size) { if($function != "scripting"){ if(trim($content[$i]) == "{script}"){ $function = "scripting"; $line = 0; }else{ $main .= $content[$i]."<br />\n"; } }else{ $linec = explode("-", $content[$i]); if($linec[0] == "File"){ $inc = $linec[1]; $handle = fopen(trim($inc), "rb"); while (!feof($handle)) { $main .= fread($handle, 8192); } fclose($handle); }elseif(trim($content[$i]) == "{/script}"){ $function = "regular"; } } $i++; } $main = bbcode($main); //$q = "SELECT * FROM themes WHERE type = '".$type."'"; //$q=mysql_query($q); //$rows=mysql_num_rows($q); // if($rows > 1){ // die("Error, there is more than one template with the name: ".$type.". Please delete one or select a different template."); // } //$css=mysql_result($result,0,"location"); //$notice=mysql_result($result,0,"notice"); $css = ""; $notice = ""; $output = "<html>\n"; $output .= "<head>\n"; $output .= "<title>".$title."</title>\n"; $output .= "<LINK href=\"".$css."\" rel=\"stylesheet\" type=\"text/css\">\n"; $output .= "</head>\n"; $output .= "<body>\n"; $output .= $main; $output .= "</body>\n"; $output .= "</html>"; return $output; } ?> What I want is to have the <br /> Not appear after DIVs (and other SPECIFIED BBcodes, not all). Maybe if there is a way to check if the line trimmed ends with ]. Any help would be appreciated. Feel free to take a copy of this script if you like it. Quote Link to comment Share on other sites More sharing options...
mattd8752 Posted February 22, 2007 Author Share Posted February 22, 2007 BUMP Quote Link to comment Share on other sites More sharing options...
mattd8752 Posted February 22, 2007 Author Share Posted February 22, 2007 BUMP Quote Link to comment Share on other sites More sharing options...
mattd8752 Posted February 22, 2007 Author Share Posted February 22, 2007 BUMP... Can anyone help? Quote Link to comment Share on other sites More sharing options...
mattd8752 Posted February 22, 2007 Author Share Posted February 22, 2007 Bump, sorry for so many, I just want to keep this active until somebody who knows how to do this comes online. Quote Link to comment Share on other sites More sharing options...
mattd8752 Posted February 22, 2007 Author Share Posted February 22, 2007 Bump Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 22, 2007 Share Posted February 22, 2007 "What I want is to have the Not appear after DIVs (and other SPECIFIED BBcodes, not all)." It's hard to help because it's not clear what you want. "Maybe if there is a way to check if the line trimmed ends with ]" Check out substr, strrpos, etc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.