<?php
$pattern = "/<[^>]+>(.*)<\/[^>]+>/U";
$subject=
<<<EOF
<b>example1</b><div align = left>this is a test</div><div>how are you</div><div>how2332ou</div>
<b>example2</b><div align = left>3this is a test</div><div>how are you</div><div>444how2332ou</div>
EOF;
if(preg_match_all($pattern,$subject,$arr)){
foreach($arr[1] as $k=>$v){
print_r($arr[1][$k]);
print_r('<br />');
}
}
else{
echo("匹配失败");
}
?>
$pattern = "/<[^>]+>(.*)<\/[^>]+>/U";
$subject=
<<<EOF
<b>example1</b><div align = left>this is a test</div><div>how are you</div><div>how2332ou</div>
<b>example2</b><div align = left>3this is a test</div><div>how are you</div><div>444how2332ou</div>
EOF;
if(preg_match_all($pattern,$subject,$arr)){
foreach($arr[1] as $k=>$v){
print_r($arr[1][$k]);
print_r('<br />');
}
}
else{
echo("匹配失败");
}
?>
输出结果:
example1
this is a test
how are you
how2332ou
example2
3this is a test
how are you
444how2332ou