Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2010, 10:14
Rasec101
 
Fecha de Ingreso: diciembre-2009
Ubicación: Santiago, Chile
Mensajes: 143
Antigüedad: 15 años, 4 meses
Puntos: 2
ayuda con duplicacionde tabla

tengo un problema estoy trayendo una tabla de una pagina externa a la cual necesito hacerle unos cambios los cuales los hago con expreciones regulares el problema es que al visualizarla me muestra la tabla que modifico 2 veces y no se como arreglarlo aca les dejo el codigo por si hay algien que me pueda ayudar ya que es urgente porfa.
Código PHP:
Ver original
  1. <?php
  2.  
  3.  
  4. $html = file_get_contents("http://xxxxxxxxxxxxxxx");
  5.  
  6.         $matches = array();
  7.         $regex = "/<\/?\w+((\s+(\w|\w[\w-]*\w)(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/i";
  8.  
  9.         $regex = "|<[^>]+>(.*)</[^>]+>|U";
  10.         preg_match_all($regex, $html, $matches, PREG_PATTERN_ORDER);
  11.        
  12.         //ver como tiene que ser para que coincida bien.
  13.         foreach ($matches as $match) {
  14.     echo '<table width="200" height="83" border="1">
  15.  <tr>
  16.    <td width="59">'.$match[17].'</td>
  17.    <td width="162">'.$match[18].'</td>
  18.    <td width="59">'.$match[22].'</td>
  19.  </tr>
  20.  <tr>
  21.    <td width="59">'.$match[23].'</td>
  22.    <td width="162">'.$match[24].'</td>
  23.    <td width="59">'.$match[28].'</td>
  24.  </tr>
  25.  <tr>
  26.    <td width="59">'.$match[29].'</td>
  27.    <td width="162">'.$match[30].'</td>
  28.    <td width="59">'.$match[34].'</td>
  29.  </tr>
  30. </table>';
  31.        
  32.         }
  33.  
  34.  
  35.  
  36. ?>

Gracias.