badaze io nel mio codice html avevo solo due div e un h2
codice HTML:
<html>
<head></head>
<body>
<div>Agosto</div>
<div>Venerdi</div>
<h2>Settembre</h2>
</body>
</html>
ma provando il tuo codice con print_r e var_dump mi fa vedere il doppio
codice HTML:
$uri = 'http://localhost/home.html';
$get = file_get_contents($uri) /*string*/ ;
$pattern = "/(<div[^>]*>(.+?)<\/div>)/msi" ;
print preg_match_all($pattern, $get, $matches);
print_r($matches);
con print_r mi da questo output
2Array ( [0] => Array ( [0] => Agosto
[1] => Venerdi
) [1] => Array ( [0] => Agosto
[1] => Venerdi
) [2] => Array ( [0] => Agosto [1] => Venerdi ) )
invece con var_dump
array(3) { [0]=> array(2) { [0]=> string(17) "Agosto
" [1]=> string(18) "Venerdi
" } [1]=> array(2) { [0]=> string(17) "Agosto
" [1]=> string(18) "Venerdi
" } [2]=> array(2) { [0]=> string(6) "Agosto" [1]=> string(7) "Venerdi" } }
inoltre ero curioso di sapere perche alla fine del pattern ci metti MSI? a che cosa serve?