kev wood Posted June 18, 2008 Share Posted June 18, 2008 where is a good place to begin to look at how to create a bulletin board? i am looking at building my own using php and want to know where to get started with this. Link to comment https://forums.phpfreaks.com/topic/110736-bb-code/ Share on other sites More sharing options...
The Little Guy Posted June 18, 2008 Share Posted June 18, 2008 http://phpsnips.com/snippet.php?id=41 Link to comment https://forums.phpfreaks.com/topic/110736-bb-code/#findComment-568110 Share on other sites More sharing options...
rarebit Posted June 18, 2008 Share Posted June 18, 2008 When doing myself I used my own regex style functions, then found these built in routines, but still not got back to trying them out... Link to comment https://forums.phpfreaks.com/topic/110736-bb-code/#findComment-568113 Share on other sites More sharing options...
thebadbad Posted June 18, 2008 Share Posted June 18, 2008 http://phpsnips.com/snippet.php?id=41 If you'd tested this function, you'd found out that you forgot to escape every single square bracket. It's an easy fix though. I also think you'll need to use the lazy (.*?) instead of (.*), to make it function with nested tags. I've used this before: <?php function bb2html($text) { $find = array( '~\[b\](.*?)\[/b\]~s', '~\[i\](.*?)\[/i\]~s', '~\[u\](.*?)\[/u\]~s', '~\[size=(.*?)\](.*?)\[/size\]~s', '~\[color=(.*?)\](.*?)\[/color\]~s', '~\[highlight=(.*?)\](.*?)\[/highlight\]~s', '~\[code\](.*?)\[/code\]~s' ); $replace = array( '<strong>$1</strong>', '<em>$1</em>', '<span style="text-decoration: underline;">$1</span>', '<span style="font-size: $1em;">$2</span>', '<span style="color: $1;">$2</span>', '<span style="background-color: $1;">$2</span>', '<pre>$1</pre>' ); return preg_replace($find, $replace, $text); } ?> Link to comment https://forums.phpfreaks.com/topic/110736-bb-code/#findComment-568117 Share on other sites More sharing options...
The Little Guy Posted June 18, 2008 Share Posted June 18, 2008 OK, I fixed them, and even with out escaping the brackets, they still worked... Link to comment https://forums.phpfreaks.com/topic/110736-bb-code/#findComment-568123 Share on other sites More sharing options...
rarebit Posted June 18, 2008 Share Posted June 18, 2008 Here's part of mine... $base = "http://www.a.b.com/icon/"; $pattern = array( '/\[b\](.+?)\[\/b\]/is', '/\[i\](.+?)\[\/i\]/is', '/\[u\](.+?)\[\/u\]/is', '/\[h1\](.+?)\[\/h1\]/is', '/\[h2\](.+?)\[\/h2\]/is', '/\[h3\](.+?)\[\/h3\]/is', '/\[h4\](.+?)\[\/h4\]/is', '/\[sub\](.+?)\[\/sub\]/is', '/\[sup\](.+?)\[\/sup\]/is', '/\[tt\](.+?)\[\/tt\]/is', '/\[s\](.+?)\[\/s\]/is', '/\[em\](.+?)\[\/em\]/is', '/\[strong\](.+?)\[\/strong\]/is', '/\[samp\](.+?)\[\/samp\]/is', '/\[kbd\](.+?)\[\/kbd\]/is', '/\[code\](.+?)\[\/code\]/is', '/\[code=(.+?)\] [/code] Link to comment https://forums.phpfreaks.com/topic/110736-bb-code/#findComment-568129 Share on other sites More sharing options...
kev wood Posted June 18, 2008 Author Share Posted June 18, 2008 thanks for the replies there is some good stuff on them. If you can think of any others that would be great i want to know all i can before i start to build. Link to comment https://forums.phpfreaks.com/topic/110736-bb-code/#findComment-568156 Share on other sites More sharing options...
rarebit Posted June 18, 2008 Share Posted June 18, 2008 maybe I should have had a gander at the preview and i'd of realised that it was half missing... no edit available... oops! Link to comment https://forums.phpfreaks.com/topic/110736-bb-code/#findComment-568160 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.