hankknight
asked on
PHP: preg_match_all parse error
My code gives a parse error and I cannot find the problem.
<pre><?php
$html = '
<div>
<div>
<p>
<strong>Hello
</p>
</div>
';
echo htmlentities(checkTags('div',$html));
function checkTags( $tag, $xml ) {
$tag = preg_quote($tag);
preg_match_all('{<'.$tag.'[^>]*>(.*?)</'.$tag.'>.'}', $xml, $matches, PREG_PATTERN_ORDER);
return $matches[1];
}
?></pre>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you tell us in plain language what you want that regular expression to do for you? There might be a better way!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found that code on this page:
http://www.catswhocode.com/blog/15-php-regular-expressions-for-web-developers
Open in new window