Hallo Forum helpers,

Onderstaand preg match laat niets zien, wat doe ik fout?




<?php
$string = file_get_contents('http://www.politie.nl/nieuws/2014/september/7/08-man-wordt-geslagen-en-beroofd.html');

preg_match_all('#<div class="contentDetail">(.*)<div class="shareBlock">#i', $string, $matches);

print_r($matches);
?>

De . in een regex matcht standaard niet op newlines en die zitten wel in de input.
Probeer het eens met een s-modifier:
<?php

preg_match_all('#<div class="contentDetail">(.*)<div class="shareBlock">#is', $string, $matches);

?>
Hoi Willem,
Bedankt, werkt nu.
Zolang je de bron maar vermeld, is het geen probleem.

Reageren