/** * Merges two lists of nodes in a single list. * * This function merges two list of nodes in a single list without repeating * nodes. * * @param array $items1 List of DOMNode objects * @param array $items2 List of DOMNode objects * * @return array of DOMNode objects */ public static function mergeNodes($items1, $items2) { $ret = array(); $items = array_merge($items1, $items2); $len = count($items); // collects non-repeated elements for ($i = 0; $i < $len; $i++) { $item = $items[$i]; $position = Dom::searchNode($item, $items, $i + 1); if ($position === false) { array_push($ret, $item); } } return $ret; }
/** * Does the node match? * * @param DOMElement $node DOMElement object * @param integer $position Node position * @param array $items List of nodes * * @return boolean */ public function match($node, $position, $items) { return Dom::searchNode($node, $this->_items) === false; }