(.+?)#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].''); 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 = '

our team
'; var_dump(g_Tag('a', $html)); /* array(1) { [0]=> array(2) { ["href"]=> string(14) "team/index.php" ["innerHTML"]=> string(78) "our team" } } */ var_dump(g_Tag('img', $html)); /* NULL -- a lil more fix... :( anyone ? */ var_dump(conv_attr('src="home/our_team.gif" alt="our team" width="70" height="16" border="0"')); /* array(5) { ["src"]=> string(17) "home/our_team.gif" ["alt"]=> string(8) "our team" ["width"]=> string(2) "70" ["height"]=> string(2) "16" ["border"]=> string(1) "0" } */ ?>