(.+?)('.$tagName.')>#is'; preg_match_all($regex, $html, $tmp); if (!is_array($tmp[2])) return false; foreach ($tmp[2] as $id => $prop) { $_tmp = g_Tag($tagName, $tmp[3][$id].''.$tagName.'>'); if (is_array($_tmp)) { $res[$id] = $_tmp[0]; } else { $res[$id]=conv_attr($prop); $res[$id]['innerHTML'] = $tmp[3][$id]; } } return $res; } function conv_attr($s) { if (!strlen(trim($s))) return false; preg_match_all('/(\w+)\s*=\s*(([\'"]).*?\3|[^"\']\S*)/', $s, $m); if (!is_array($m[0])) { $s = explode(" ", $s); foreach ($s as $k) $res[$k]=$k; return $res; } else { foreach ($m[1] as $id => $key) { $s = trim(str_replace($m[0][$id],'', $s)); $value = (strlen($m[3][$id]))?substr($m[2][$id],1,-1):$m[2][$id]; $res[$key] = $value; } $s = explode(" ", $s); if (is_array($s)) foreach ($s as $k) if (strlen($k)) $res[trim($k)]=trim($k); } return $res; } $html = '
![]()
';
var_dump(g_Tag('a', $html));
/*
array(1) {
[0]=>
array(2) {
["href"]=>
string(14) "team/index.php"
["innerHTML"]=>
string(78) "
"
}
}
*/
var_dump(g_Tag('img', $html));
/*
NULL
--
a lil more fix... :( anyone ?
*/
?>