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 Quote Link to comment 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 ! Quote Link to comment 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; } Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 3, 2007 Author Share Posted April 3, 2007 anybody have any ideas? Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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?? Quote Link to comment 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 :-\ Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 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.