Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/09/2011, 09:32
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Reemplazar Etiquetas

Podrías hacer algo así, pasa por el área de aportes para que veas un tema que te puede ayudar a desenvolverte con expresiones regulares.
Código PHP:
Ver original
  1. <?php
  2. $str_to_edit = '<span class="underline"> It was popularised in the 1960s with the release of Letraset
  3.     sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like
  4.     Aldus PageMaker including versions of Lorem Ipsum.</span>Lorem Ipsum is simply dummy text of the
  5.     printing and typesetting industry.<br /></span><span class="italic">Lorem Ipsum is simply dummy
  6.     text of the printing and typesetting industry.<br /></span><span class="underline">Lorem Ipsum is
  7.     simply dummy text of the printing and typesetting industry.</span><br /><br />
  8.     <span class="italic bold">Lorem Ipsum is simply dummy text of the printing and typesetting
  9.     industry.<br /></span><span class="bold italic">Lorem Ipsum is simply dummy text of the printing
  10.     and typesetting industry.<br /></span><span class="underline italic bold">Lorem Ipsum is simply
  11.     dummy text of the printing and typesetting industry.</span>';
  12. $find = array('<span class="underline">', '</span>');
  13. $replace = array('<b><i>', '</i></i>');
  14. $str = preg_replace('/<span.*?>(.+?)<\/span>/is', '<b><i>$1</i></b>', $str_to_edit);
  15. echo $str;
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos