0

this copy as such of a web but I don't doing that show the value within div :/

<div style="float:left;">
    CARRERA 7H BIS No. 76 - 0 ALFONSO  II                                                                               
</div>

preg_match('|<div style="float:left;">(.*+)</div>|is' , $data , $cap );
echo "direccion: ".$cap[1].'<br>';
Delimitry
  • 2,987
  • 4
  • 30
  • 39

1 Answers1

0
$data= '<div style="float:left;">CARRERA 7H BIS No. 76 - 0 ALFONSO  II    </div>';
preg_match('%<div style="float:left;">(.*?)<\/div>%si', $data , $cap );
echo "direccion: ".$cap[1].'<br>';

So, you was close, but you didn't escaped closing div - that was problem. P.S. And capturing group regex was false - this one should work. At the end 's' modifier is added - in case that new lines are in input ($data).

Updated regex for direccion:

$regex="%<div style='float:left;'>(.*?)<\/div>%si";
preg_match($regex, $data , $cap );
echo "direccion: ".$cap[1].'<br>';
sinisake
  • 11,240
  • 2
  • 19
  • 27
  • Send example of data you got... Without it - we can just guess. This regex works on example from your question (tested). – sinisake Mar 17 '15 at 20:02
  • That's better - and you need: Departamento: CAUCA Municipio: TIMBIO Puesto: PUESTO CABECERA MUNICIPAL Dirección Puesto: I.E. CONC ESC GUILLERMO VALENC Fecha de inscripción: Jan 2 2014 10:37AM Mesa 42 i guess? P.S. - there are no double quotes there... – sinisake Mar 17 '15 at 20:13