maxudaskin Posted June 21, 2008 Share Posted June 21, 2008 I made a forum, and I decided that a quoting system was in order. I quietly edited the bbcode list and now I was wondering: Can I make it multi-line? (See image 1 and 2) Can I put a quote in a quote? (See image 3) Image 1 Text This is a quote test. [quote]This is quoted text.[/quote] This is a colour test. [blue]The is blue.[/blue] [red]This is red.[/red] Current Project: [b]Debugging Quote System[/b] Image 2 Text This is a quote test. [quote]This is quoted text. This is a second line.[/quote] This is a colour test. [blue]The is blue.[/blue] [red]This is red.[/red] Current Project: [b]Debugging Quote System[/b] Image 3 Text This is a quote test. [quote]This is quoted text.[quote]This is a quote inside a quote.[/quote][/quote] This is a colour test. [blue]The is blue.[/blue] [red]This is red.[/red] Current Project: [b]Debugging Quote System[/b] Source Code (Amended) <?php $text = $posts['text']; $message = preg_replace($find,$rplc,$text); preg_match_all('/\[img\](.+?)\[\/img\]/', $text, $url); $imagekeys = array_keys($url[1]); for($i=0;$i<count($imagekeys);$i++){ echo "<img src\""; print_r($url[$i][0]); echo "\" height=\"" . $height . "\" width=\"" . $width . "\" alt=\"We Cannot Find This Specified Image\" /><br />"; } $message = str_replace($smilies,$locations,$message); $pattern = '% (http://)? ### optional http:// prefix (?(1)|www\.) ### require www. if there is no http:// \S+ ### gobble anything but white space %x'; $message = preg_replace_callback($pattern, 'clickable_short_url', $message); // Change URLs into links echo nl2br($message); ?> <?php // BBCode $find=array( "/\[b\](.*)\[\/b\]/", "/\[i\](.*)\[\/i\]/", "/\[u\](.*)\[\/u\]/", "/\[img\](.*)\[\/img\]/", "/\[link\](.*)\[\/link\]/", "/\[big\](.*)\[\/big\]/", "/\[small\](.*)\[\/small\]/", "/\[red\](.*)\[\/red\]/", "/\[blue\](.*)\[\/blue\]/", "/\[green\](.*)\[\/green\]/", "/\[quote\](.*)\[\/quote\]/" ); $rplc=array( "<b>$1</b>", "<i>$1</i>", "<u>$1</u>", "<img src='$1'/>", "<a href='$1'>$1</a>", "<h1>$1</h1>", "<h4>$1</h4>", "<font color='red'>$1</font>", "<font color='blue'>$1</font>", "<font color='green'>$1</font>", "<div class='forumquote'>$1</div>" ); ?> Style .forumquote { text-align: left; background: #efefef; color: #333; border: 1px inset #333; font-family: "Courier New", Courier, monospace; padding: 5px; margin: auto; width: 90%; max-height: 200px; overflow: auto; } Image 1 Image 2 Image 3 Quote Link to comment https://forums.phpfreaks.com/topic/111203-solved-preg_replace-question/ Share on other sites More sharing options...
sasa Posted June 21, 2008 Share Posted June 21, 2008 try $find=array( "/\[b\](.*)\[\/b\]/", "/\[i\](.*)\[\/i\]/", "/\[u\](.*)\[\/u\]/", "/\[img\](.*)\[\/img\]/", "/\[link\](.*)\[\/link\]/", "/\[big\](.*)\[\/big\]/", "/\[small\](.*)\[\/small\]/", "/\[red\](.*)\[\/red\]/", "/\[blue\](.*)\[\/blue\]/", "/\[green\](.*)\[\/green\]/", //"/\[quote\](.*)\[\/quote\]/" "/\[quote\]/", "/\[\/quote\]/" ); $rplc=array( "<b>$1</b>", "<i>$1</i>", "<u>$1</u>", "<img src='$1'/>", "<a href='$1'>$1</a>", "<h1>$1</h1>", "<h4>$1</h4>", "<font color='red'>$1</font>", "<font color='blue'>$1</font>", "<font color='green'>$1</font>", //"<div class='forumquote'>$1</div>" "<div class='forumquote'>", "</div>" ); Quote Link to comment https://forums.phpfreaks.com/topic/111203-solved-preg_replace-question/#findComment-570778 Share on other sites More sharing options...
maxudaskin Posted June 21, 2008 Author Share Posted June 21, 2008 Thank you. It worked. Quote Link to comment https://forums.phpfreaks.com/topic/111203-solved-preg_replace-question/#findComment-570787 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.