Hi!
I've got some trouble and questions about preg-patterns. I'me trying to build two simple functions to get the name and attributes from a tag ( XML or HTML, doesn't matter ).
I've tried this:
function getName ( $tag ) {
preg_match_all ( "|<([<|\040|>].*?)>|is", $tag, $out );
return $out[ 1 ][ 0 ];
}
fuction getAttributes ( $tag ) {
preg_match_all ( "|<([<|>].*?)>|is", $tag, $out );
$arr = explode ( " ", $out[ 1 ][ 0 ] );
for ( $i = 1; $i < count ( $arr ); $i++ ) {
$currentArr = explode ( "=", $arr[ $i ] );
$resultArr[] = $currentArr[ 0 ];
}
return $resultArr;
}
Anyone with a smart tip? I've be really greatful. :-)
Thanks in advance!
Regards,
Bjornie