Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/09/2010, 08:53
kirst
 
Fecha de Ingreso: septiembre-2009
Mensajes: 230
Antigüedad: 14 años, 7 meses
Puntos: 2
BBCode a HTML

function.php
Código PHP:
function BBcode($texto){
   
$texto htmlentities($texto);
   
$a = array(
      
"/\[i\](.*?)\[\/i\]/is",
      
"/\[b\](.*?)\[\/b\]/is",
      
"/\[u\](.*?)\[\/u\]/is",
      
"/\[img\](.*?)\[\/img\]/is",
      
"/\[url=(.*?)\](.*?)\[\/url\]/is",
      
"/\[quote=(.*?)\](.*?)\[\/quote\]/is"
   
);
   
$b = array(
      
"<i>$1</i>",
      
"<b>$1</b>",
      
"<u>$1</u>",
      
"<img src=\"$1\" />",
      
"<a href=\"$1\">$2</a>",
      
"Cita:<br/> <div class=\"quote\">Empezado por: <b>$1</b><br/> <i>$2</i></div>"
   
);
   
$texto preg_replace($a$b$texto);
      
$texto nl2br($texto);
   return 
$texto;

Lo que quiero, es invertirla... Necesito volcar el contenido que meto nuevamente en un textarea (sea para editar, para hacerle un quote, etc). Quiero que se entienda bien, no quiero que de BBCODE liste HTML, quiero que DE HTML tire a BBCODE, así luego éste se pueda utilizar en un textarea.