almightyegg Posted April 3, 2007 Share Posted April 3, 2007 function emoticon($post) { $emoticonarray = array( '' => 'smile.gif', '' => 'sad.gif', '' => 'wink.gif', '' => 'tongue.gif', '' => 'cheese.gif' ); foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="http://lordoftheabyss.com/images/emotions/' . $img . '" alt="' . $emoticon . '" />'; } $post = str_replace($search, $replace, $post); return $post; } function bbcode_format($post) { $post = htmlentities($post); $simple_search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is' ); $simple_replace = array( '<strong>$1</strong>', '<em>$1</em>', '<u>$1</u>' ); // Do simple BBCode's $post = preg_replace ($simple_search, $simple_replace, $post); return $post; } It still shows smilies, but not the bbcodes Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/ Share on other sites More sharing options...
DeathStar Posted April 3, 2007 Share Posted April 3, 2007 [ CODE ][ /CODE ] if realy gonna count how many times i say this ! Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220389 Share on other sites More sharing options...
almightyegg Posted April 3, 2007 Author Share Posted April 3, 2007 yu mean yo want me to put in code box? function emoticon($post) { $emoticonarray = array( '' => 'smile.gif', '' => 'sad.gif', '' => 'wink.gif', '' => 'tongue.gif', '' => 'cheese.gif' ); foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="http://lordoftheabyss.com/images/emotions/' . $img . '" alt="' . $emoticon . '" />'; } $post = str_replace($search, $replace, $post); return $post; } function bbcode_format($post) { $post = htmlentities($post); $simple_search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is' ); $simple_replace = array( '<strong>$1</strong>', '<em>$1</em>', '<u>$1</u>' ); // Do simple BBCode's $post = preg_replace ($simple_search, $simple_replace, $post); return $post; } Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220391 Share on other sites More sharing options...
DeathStar Posted April 3, 2007 Share Posted April 3, 2007 What are the script outputting now? an erro or just the Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220398 Share on other sites More sharing options...
almightyegg Posted April 3, 2007 Author Share Posted April 3, 2007 the value of post is: [ b ]text[/b ][ u ]text[/u ][ i ]text[/i ] (except without the spaces) No actual errors, it just doesn't show the bold, underline or italic, but it does show the smiley Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220400 Share on other sites More sharing options...
almightyegg Posted April 3, 2007 Author Share Posted April 3, 2007 anybody have any ideas? Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220434 Share on other sites More sharing options...
only one Posted April 3, 2007 Share Posted April 3, 2007 example $bbcode = array('/(\[url=)(.*)(\])(.*)(\[\/url\])/'); $html = array( '<a href="http://${2}" target=_blank>${4}</a>'); $output = preg_replace($bbcode, $html, $output); if you want it to red you [ b ]text[/b ][ u ]text[/u ] [ i ]text[/i ] then you have to do: $bbcode array('/(\[b\])(.*)(\[\/b\])(\[u\])(.*)(\[\/u\])(\[i\])(.*)(\[\/i\])/'); $html = array('<strong>${2}</strong><u>${3}</u><i>${4}'); hope that makes sense Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220449 Share on other sites More sharing options...
almightyegg Posted April 3, 2007 Author Share Posted April 3, 2007 Wha? lol. Sorry I'm a n00b...but what do I have to do to my original code? Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220452 Share on other sites More sharing options...
only one Posted April 3, 2007 Share Posted April 3, 2007 <?php function emoticon($post) { $emoticonarray = array( '' => 'smile.gif', '' => 'sad.gif', '' => 'wink.gif', '' => 'tongue.gif', '' => 'cheese.gif' ); foreach($emoticonarray as $emoticon => $img) { $search[] = $emoticon; $replace[] = '<img src="http://lordoftheabyss.com/images/emotions/' . $img . '" alt="' . $emoticon . '" />'; } $post = str_replace($search, $replace, $post); return $post; } function bbcode_format($post) { $post = htmlentities($post); $simple_search = array('/(\[b\])(.*)(\[\/b\])(\[u\])(.*)(\[\/u\])(\[i\])(.*)(\[\/i\])/' ); $simple_replace = array('<strong>${2}</strong><u>${3}</u><i>${4}</i>'); // Do simple BBCode's $post = preg_replace ($simple_search, $simple_replace, $post); return $post; } ?> this will only work for the [ b ][/b ][ u ][/u ][ i ][/i ] order Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220457 Share on other sites More sharing options...
almightyegg Posted April 3, 2007 Author Share Posted April 3, 2007 what if it's: texttexttexttext or something like that ?? Surely it would be impossible to do it the way you've said?? Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220460 Share on other sites More sharing options...
only one Posted April 3, 2007 Share Posted April 3, 2007 thats the problem with this, it is nearly impossible unless you make all the ways its possible which would take you forever :-\ Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220462 Share on other sites More sharing options...
almightyegg Posted April 3, 2007 Author Share Posted April 3, 2007 there's infinitive ways, lol! I would be there forever But, I got my script off of a website tutorial...so is it the site that is messed up or me? Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220466 Share on other sites More sharing options...
only one Posted April 3, 2007 Share Posted April 3, 2007 http://www.tutorio.com/tutorial/simple-and-complex-bbcode-with-php check that, should explain quite a bit i hope Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220468 Share on other sites More sharing options...
almightyegg Posted April 3, 2007 Author Share Posted April 3, 2007 I've actually just half fixed it! I had a made an error in echoing it lol now have: $post = bbcode_format(emoticon($updates[uptext])); but the smiliy doesn't show now, the underline/bold/italic etc works now Link to comment https://forums.phpfreaks.com/topic/45393-solved-bbcode-problem/#findComment-220471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.