HTMLPurifier_Zipper::splice PHP Method

splice() public method

$arr1 = $arr; $old1 = array_splice($arr1, $i, $delete, $replacement); list($z, $t) = HTMLPurifier_Zipper::fromArray($arr); $t = $z->advance($t, $i); list($old2, $t) = $z->splice($t, $delete, $replacement); $arr2 = $z->toArray($t); assert($old1 === $old2); assert($arr1 === $arr2); NB: the absolute index location after this operation is *unchanged!*
public splice ( $t, $delete, $replacement )
    public function splice($t, $delete, $replacement)
    {
        // delete
        $old = array();
        $r = $t;
        for ($i = $delete; $i > 0; $i--) {
            $old[] = $r;
            $r = $this->delete();
        }
        // insert
        for ($i = count($replacement) - 1; $i >= 0; $i--) {
            $this->insertAfter($r);
            $r = $replacement[$i];
        }
        return array($old, $r);
    }