Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/05/2005, 16:22
Avatar de Seppo
Seppo
 
Fecha de Ingreso: marzo-2005
Ubicación: Buenos Aires, Argentina
Mensajes: 1.284
Antigüedad: 19 años, 1 mes
Puntos: 17
En http://ar2.php.net/manual/es/function.htmlentities.php en los comentarios está la respuesta exacta a tu pregunta

Código PHP:
//a function to encode everything but html tags. pattern improvement is much appreciated!

function htmlEncodeText ($string)
{
  
$pattern '<([a-zA-Z0-9\. "\'_\/-=;\(\)?&#%]+)>';
  
preg_match_all ('/' $pattern '/'$string$tagMatchesPREG_SET_ORDER);
  
$textMatches preg_split ('/' $pattern '/'$string);

  foreach (
$textMatches as $key => $value) {
   
$textMatches [$key] = htmlentities ($value);
  }

  for (
$i 0$i count ($textMatches); $i ++) {
   
$textMatches [$i] = $textMatches [$i] . $tagMatches [$i] [0];
  }

  return 
implode ($textMatches);