Jump to content

[SOLVED] bbcode problem


almightyegg

Recommended Posts

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

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

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

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.