I wanna match words between tags. like this
Code: Select all
<tag1> hello world </tag1>Code: Select all
<?php
$string = <<<END
<tag1>without linebrakes works ok!!!</tag1>
<tag2>After this a linebreak.
linebreak
linebreak
linebreak
didnt work!!!</tag2>
END;
preg_match('/<(tag1)>(.+?)<\/\1>/', $string, $match );
preg_match('/<(tag2)>(.+?)<\/\1>/', $string, $match2 );
echo '<pre>';
print_r($match);
print_r($match2); //no match!!!
echo '</pre>';
?>