Part of the EllisLab Network
x
 
Create New Page
 View Previous Changes    ( Last updated by aventro )

BBCode Helper 2

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! 
function_exists('bbcode'))
{
    
function bbcode($str '')
    
{
        $ci 
=& get_instance();
        
$ci->load->helper('url');
     
        
$str $ci->security->xss_clean($str);
     
        
$str strip_tags($str'<img>');
        
$str auto_link($str);
        
        
$str nl2br($str);
        
        
$find = array(
            
"~\[b\](.*?)\[/b\]~is",
            
"~\[i\](.*?)\[/i\]~is");
            
        
$replace = array(
            
'<b>\\1</b>',
            
'<i>\\1</i>');
            
        return 
preg_replace($find$replace$str);  
    
}
Features

[b][
/b] Bold
[i][
/i] Italic
http
://url/ Url
<img src="" alt="" /> Image
\n 
<br> New lines

Improve :)