Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/05/2005, 23:57
sebtev
 
Fecha de Ingreso: enero-2004
Ubicación: Salto
Mensajes: 484
Antigüedad: 20 años, 3 meses
Puntos: 2
Brother guau q manera de escribir... prueba con esto, es lo q yo uso (no lo escribi, pero tampoco me acuerdo del autor, hace mucho ya... me estoy volviendo viejo)
Código PHP:
<?
function formatear_salida($salida)
{
    return 
htmlspecialchars(stripslashes($salida));
}
function 
salida($a)
{
    
//$a=color_source($a);
    
$cadena_fuente = array(
    
'[A]',
    
'[/A]',
    
'[B]',
    
'[/B]',
    
'[I]',
    
'[/I]',
    
'[U]',
    
'[/U]',
    
'[C]',
    
'[/C]',
    
'[RED]',
    
'[/RED]',
    
'[BLUE]',
    
'[/BLUE]',
    
'[GREEN]',
    
'[/GREEN]'
    
);
    
$cadena_salida = array(
    
'<span style="text-transform:uppercase;">',
    
'</span>;',
    
'<strong>',
    
'</strong>',
    
'<em>',
    
'</em>',
    
'<u>',
    
'</u>',
    
'<span align="center">',
    
'</span>',
    
'<span style="color:red;">',
    
'</span>',
    
'<span style="color:blue;">',
    
'</span>',
    
'<span style="color:green;">',
    
'</span>'
    
);
    
$a=htmlspecialchars($a);
    
$a=strip_tags($a);
    
$a=nl2br($a);
    
$a=buscar_y_reemplazar($cadena_fuente,$cadena_salida,$a);
    
//$a=utf8_decode($a);
    
return $a;
}
function 
buscar_y_reemplazar($find,$replace,$string)
{
    if(!
is_array($find)) $find = array($find);
    if(!
is_array($replace))
    {
        if(!
is_array($find)) $replace = array($replace);
        else
        {
            
// this will duplicate the string into an array the size of $find
            
$c count($find);
            
$rString $replace;
            unset(
$replace);
            for (
$i 0$i $c$i++)
            {
                
$replace[$i] = $rString;
            }
        }
    }
    foreach(
$find as $fKey => $fItem)
    {
        
$between explode(strtolower($fItem),strtolower($string));
        
$pos 0;
        foreach(
$between as $bKey => $bItem)
        {
            
$between[$bKey] = substr($string,$pos,strlen($bItem));
            
$pos += strlen($bItem) + strlen($fItem);
        }
        
$string implode($replace[$fKey],$between);
    }
    return(
$string);
}
?>
Nada complicado, lo incluyes a las páginas q lo van a usar, le agregas lo q quieras (todos esos emoticones q estas usando), etc.
Funciona OK, no me da drama...
Saludos cuidate
__________________
Dios dira que esto no es justo, pero lo sera...