public function sliceByKey($mStartKey, $bStrict = true, $iLength = PHP_INT_MAX)
    {
        $aSlice = array();
        try {
            $this->seekToKey($mStartKey, $bStrict);

            if ($iLength > 0) {
                $aSlice[$this->key()] = $this->current();
                $iLength--;
                $this->next();
            }

            while ($iLength > 0 and true === $this->valid()) {
                $aSlice[$this->key()] = $this->current();
                $iLength--;
                $this->next();
            }
        } catch (\OutOfBoundsException $e) {
            //do nothing if key not exists
        }
        $sClassName = get_class($this);

        return new $sClassName($aSlice);
    }
public function sliceByKey($mStartKey, $bStrict = true, $iLength = PHP_INT_MAX)
    {
        $aSlice = array();
        try {
            $this->seekToKey($mStartKey, $bStrict);

            if ($iLength > 0) {
                $aSlice[$this->key()] = $this->current();
                $iLength--;
                $this->next();
            }

            while ($iLength > 0 and true === $this->valid()) {
                $aSlice[$this->key()] = $this->current();
                $iLength--;
                $this->next();
            }
        } catch (\OutOfBoundsException $e) {
            //do nothing if key not exists
        }
        $sClassName = get_class($this);

        return new $sClassName($aSlice);
    }
public function sliceByKey ( $ mStartKey , $ bStrict = true , $ iLength = PHP_INT_MAX ) { $ aSlice = array ( ) ; try { $ this -> seekToKey ( $ mStartKey , $ bStrict ) ; if ( $ iLength > 0 ) { $ aSlice [ $ this -> key ( ) ] = $ this -> current ( ) ; $ iLength -- ; $ this -> next ( ) ; } while ( $ iLength > 0 and true === $ this -> valid ( ) ) { $ aSlice [ $ this -> key ( ) ] = $ this -> current ( ) ; $ iLength -- ; $ this -> next ( ) ; } } catch ( \ OutOfBoundsException $ e ) { //do nothing if key not exists } $ sClassName = get_class ( $ this ) ; return new $ sClassName ( $ aSlice ) ; }
Slice elements and create a new instance

@param mixed $mStartKey
@param bool  $bStrict
@param int   $iLength

@return AbstractCollection
Slice elements and create a new instance