almightyegg Posted September 14, 2007 Share Posted September 14, 2007 I decided to add a language filter to my BBcodes function I used a test post yet it seemed the words appeared normally (I have filled the words with ---- for uses on tis board) function bbcode_format($post) { $post = htmlentities($post); $simple_search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[center\](.*?)\[\/center\]/is', '/\[right\](.*?)\[\/right\]/is', '/\[img=(.*?)\]/is', '/\[(.*?)\](.*?)\[\/url]/is', '/\[colour=(.*?)\](.*?)\[\/colour]/is', '/\[quote\](.*?)\[\/quote]/is', '/\[br]/is', '/\[hr]/is', '/\[h1](.*?)\[\/h1\]/is', '/\[h2](.*?)\[\/h2\]/is', '/\[h3](.*?)\[\/h3\]/is', '/\----/is', '/\----/is', '/\----/is', '/\----/is' ); $simple_replace = array( '<strong>$1</strong>', '<em>$1</em>', '<u>$1</u>', '<center>$1</center>', '<right>$1</right>', '<img src="$1">', '<a href="$1">$2</a>', '<font color=$1>$2</font>', '<br><table border=0 bgcolor=#000000><td>$1</td></table><br>', '<br>', '<hr>', '<h1>$1</h1>', '<h2>$1</h2>', '<h3>$1</h3>', 'f***', 's***', 't***', 'c***' ); // Do simple BBCode's $post = preg_replace ($simple_search, $simple_replace, $post); return $post; } Link to comment https://forums.phpfreaks.com/topic/69360-solved-problems-with-bbcode-function/ Share on other sites More sharing options...
almightyegg Posted September 15, 2007 Author Share Posted September 15, 2007 any ideas guys? Link to comment https://forums.phpfreaks.com/topic/69360-solved-problems-with-bbcode-function/#findComment-349085 Share on other sites More sharing options...
rarebit Posted September 15, 2007 Share Posted September 15, 2007 It works! <?php function bbcode_format($post) { $post = htmlentities($post); $simple_search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[center\](.*?)\[\/center\]/is', '/\[right\](.*?)\[\/right\]/is', '/\[img=(.*?)\]/is', '/\[(.*?)\](.*?)\[\/url]/is', '/\[colour=(.*?)\](.*?)\[\/colour]/is', '/\[quote\](.*?)\[\/quote]/is', '/\[br]/is', '/\[hr]/is', '/\[h1](.*?)\[\/h1\]/is', '/\[h2](.*?)\[\/h2\]/is', '/\[h3](.*?)\[\/h3\]/is', '/\----/is', '/\----/is', '/\----/is', '/\----/is' ); $simple_replace = array( '<strong>$1</strong>', '<em>$1</em>', '<u>$1</u>', '<center>$1</center>', '<right>$1</right>', '<img src="$1">', '<a href="$1">$2</a>', '<font color=$1>$2</font>', '<br><table border=0 bgcolor=#000000><td>$1</td></table><br>', '<br>', '<hr>', '<h1>$1</h1>', '<h2>$1</h2>', '<h3>$1</h3>', 'f***', 's***', 't***', 'c***' ); // Do simple BBCode's $post = preg_replace ($simple_search, $simple_replace, $post); return $post; } $post = "[b]hello[/b]"; $p = bbcode_format($post); echo $post."<br>"; echo $p."<br>"; ?> Link to comment https://forums.phpfreaks.com/topic/69360-solved-problems-with-bbcode-function/#findComment-349090 Share on other sites More sharing options...
almightyegg Posted September 15, 2007 Author Share Posted September 15, 2007 It was the language filter that didn't work, I just managed to get it going it should've been '/f--k/is', instead of '/\f--f/is' Link to comment https://forums.phpfreaks.com/topic/69360-solved-problems-with-bbcode-function/#findComment-349092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.