public static function filterOutElements($children, $lookup)
    {
        if (!is_array($lookup)) {
            $lookup = array($lookup => true);
        }

        // backward compatibility - ensure provided array is a lookup
        foreach ($lookup as $key => $value) {
            if (!is_string($key)) {
                unset($lookup[$key]);
                $lookup[$value] = true;
            }
        }

        $result = array();
        foreach ((array) $children as $child) {
            if ($child instanceof HTMLPurifier_Node_Element) {
                $filteredChildren = self::filterOutElements($child->children, $lookup);
                if (isset($lookup[$child->name])) {
                    // don't add removed element, only its children
                    foreach ($filteredChildren as $c) {
                        $result[] = $c;
                    }
                    continue;
                }
                $child->children = $filteredChildren;
            }
            $result[] = $child;
        }

        return $result;
    }
public static function filterOutElements($children, $lookup)
    {
        if (!is_array($lookup)) {
            $lookup = array($lookup => true);
        }

        // backward compatibility - ensure provided array is a lookup
        foreach ($lookup as $key => $value) {
            if (!is_string($key)) {
                unset($lookup[$key]);
                $lookup[$value] = true;
            }
        }

        $result = array();
        foreach ((array) $children as $child) {
            if ($child instanceof HTMLPurifier_Node_Element) {
                $filteredChildren = self::filterOutElements($child->children, $lookup);
                if (isset($lookup[$child->name])) {
                    // don't add removed element, only its children
                    foreach ($filteredChildren as $c) {
                        $result[] = $c;
                    }
                    continue;
                }
                $child->children = $filteredChildren;
            }
            $result[] = $child;
        }

        return $result;
    }
public static function filterOutElements ( $ children , $ lookup ) { if ( ! is_array ( $ lookup ) ) { $ lookup = array ( $ lookup => true ) ; } // backward compatibility - ensure provided array is a lookup foreach ( $ lookup as $ key => $ value ) { if ( ! is_string ( $ key ) ) { unset ( $ lookup [ $ key ] ) ; $ lookup [ $ value ] = true ; } } $ result = array ( ) ; foreach ( ( array ) $ children as $ child ) { if ( $ child instanceof HTMLPurifier_Node_Element ) { $ filteredChildren = self :: filterOutElements ( $ child -> children , $ lookup ) ; if ( isset ( $ lookup [ $ child -> name ] ) ) { // don't add removed element, only its children foreach ( $ filteredChildren as $ c ) { $ result [ ] = $ c ; } continue ; } $ child -> children = $ filteredChildren ; } $ result [ ] = $ child ; } return $ result ; }
Helper method for recursive elements removal

@param HTMLPurifier_Node[] $children
@param string|string[] $lookup
@return HTMLPurifier_Node[]
Helper method for recursive elements removal