simplehtmldom_1_5\simple_html_dom_node::find_ancestor_tag PHP Method

find_ancestor_tag() public method

function to locate a specific ancestor tag in the path to the root.
public find_ancestor_tag ( $tag )
    function find_ancestor_tag($tag)
    {
        global $debugObject;
        if (is_object($debugObject)) {
            $debugObject->debugLogEntry(1);
        }
        // Start by including ourselves in the comparison.
        $returnDom = $this;
        while (!is_null($returnDom)) {
            if (is_object($debugObject)) {
                $debugObject->debugLog(2, "Current tag is: " . $returnDom->tag);
            }
            if ($returnDom->tag == $tag) {
                break;
            }
            $returnDom = $returnDom->parent;
        }
        return $returnDom;
    }