QueryPath\DOMQuery::slice PHP Method

slice() public method

Narrow the items in this object down to only a slice of the starting items.
See also: array_slice()
public slice ( integer $start, integer $length )
$start integer Where in the list of matches to begin the slice.
$length integer The number of items to include in the slice. If nothing is specified, the all remaining matches (from $start onward) will be included in the sliced list.
    public function slice($start, $length = 0)
    {
        $end = $length;
        $found = new \SplObjectStorage();
        if ($start >= $this->size()) {
            return $this->inst($found, null, $this->options);
        }
        $i = $j = 0;
        foreach ($this->matches as $m) {
            if ($i >= $start) {
                if ($end > 0 && $j >= $end) {
                    break;
                }
                $found->attach($m);
                ++$j;
            }
            ++$i;
        }
        return $this->inst($found, null, $this->options);
    }