Created
April 19, 2012 11:32
-
-
Save jnaskali/2420386 to your computer and use it in GitHub Desktop.
PHP: Match HTML/XML tag with regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_tag( $tag, $xml ) { | |
$tag = preg_quote($tag); | |
preg_match_all('{<'.$tag.'[^>]*>(.*?)</'.$tag.'>.'}', | |
$xml, | |
$matches, | |
PREG_PATTERN_ORDER); | |
return $matches[1]; | |
} | |
// source http://www.catswhocode.com/blog/15-php-regular-expressions-for-web-developers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment