Ver Mensaje Individual
  #6 (permalink)  
Antiguo 03/05/2013, 19:42
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: como hacer esto con preg_match

Yo prefiero usar DOM para temas de html

Código PHP:
Ver original
  1. <?php
  2.  
  3. $fuente = '
  4. <a href="link"><span>ESTA ES LA <strong>PRIMERA</strong> CADENA</span></a>
  5. <a href="link"><span>ESTA ES LA <strong>SEGUNDA</strong> CADENA</span></a>
  6. <a href="link"><span>ESTA ES LA <strong>TERCERA</strong> CADENA</span></a>
  7. <a href="link"><span>ESTA ES LA <strong>CUARTA</strong> CADENA</span></a>';
  8.  
  9. $doc = new DOMDocument();
  10. $doc->loadHTML($fuente);
  11. $enlaces = $doc->getElementsByTagName('a');
  12.  
  13. foreach ($enlaces as $enlace) {
  14.     echo $enlace->nodeValue . '<br />';
  15. }

Cita:
ESTA ES LA PRIMERA CADENA
ESTA ES LA SEGUNDA CADENA
ESTA ES LA TERCERA CADENA
ESTA ES LA CUARTA CADENA
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP