public function slice($start_index, $end_index = NULL) {
    if ($start_index < 0) {
      $start_index = $this->count() + $start_index;
    }
    if ($end_index < 0) {
      $end_index = $this->count() + $end_index;
    }
    $last_index = $this->count() - 1;
    if ($start_index > $last_index) {
      $start_index = $last_index;
    }
    if ($end_index !== NULL) {
      if ($end_index > $last_index) {
        $end_index = $last_index;
      }
      if ($start_index > $end_index) {
        $start_index = $end_index;
      }
      $length = $end_index - $start_index;
    }
    else {
      $length = $this->count() - $start_index;
    }
    return new NodeCollection(array_slice($this->nodes, $start_index, $length));
  }
public function slice($start_index, $end_index = NULL) {
    if ($start_index < 0) {
      $start_index = $this->count() + $start_index;
    }
    if ($end_index < 0) {
      $end_index = $this->count() + $end_index;
    }
    $last_index = $this->count() - 1;
    if ($start_index > $last_index) {
      $start_index = $last_index;
    }
    if ($end_index !== NULL) {
      if ($end_index > $last_index) {
        $end_index = $last_index;
      }
      if ($start_index > $end_index) {
        $start_index = $end_index;
      }
      $length = $end_index - $start_index;
    }
    else {
      $length = $this->count() - $start_index;
    }
    return new NodeCollection(array_slice($this->nodes, $start_index, $length));
  }
public function slice ( $ start_index , $ end_index = NULL ) { if ( $ start_index < 0 ) { $ start_index = $ this -> count ( ) + $ start_index ; } if ( $ end_index < 0 ) { $ end_index = $ this -> count ( ) + $ end_index ; } $ last_index = $ this -> count ( ) - 1 ; if ( $ start_index > $ last_index ) { $ start_index = $ last_index ; } if ( $ end_index !== NULL ) { if ( $ end_index > $ last_index ) { $ end_index = $ last_index ; } if ( $ start_index > $ end_index ) { $ start_index = $ end_index ; } $ length = $ end_index - $ start_index ; } else { $ length = $ this -> count ( ) - $ start_index ; } return new NodeCollection ( array_slice ( $ this -> nodes , $ start_index , $ length ) ) ; }
Reduce the set of matched nodes to a subset specified by a range.
@param int $start_index
@param int $end_index
@return NodeCollection
Reduce the set of matched nodes to a subset specified by a range .