protected function _toSequenceString($sort = true)
    {
        if (empty($this->_ids)) {
            return '';
        }

        $in = $this->_ids;

        if ($sort && !$this->_sorted) {
            $this->_sort($in);
        }

        $first = $last = array_shift($in);
        $i = count($in) - 1;
        $out = array();

        foreach ($in as $key => $val) {
            if (($last + 1) == $val) {
                $last = $val;
            }

            if (($i == $key) || ($last != $val)) {
                if ($last == $first) {
                    $out[] = $first;
                    if ($i == $key) {
                        $out[] = $val;
                    }
                } else {
                    $out[] = $first . ':' . $last;
                    if (($i == $key) && ($last != $val)) {
                        $out[] = $val;
                    }
                }
                $first = $last = $val;
            }
        }

        return empty($out)
            ? $first
            : implode(',', $out);
    }
protected function _toSequenceString($sort = true)
    {
        if (empty($this->_ids)) {
            return '';
        }

        $in = $this->_ids;

        if ($sort && !$this->_sorted) {
            $this->_sort($in);
        }

        $first = $last = array_shift($in);
        $i = count($in) - 1;
        $out = array();

        foreach ($in as $key => $val) {
            if (($last + 1) == $val) {
                $last = $val;
            }

            if (($i == $key) || ($last != $val)) {
                if ($last == $first) {
                    $out[] = $first;
                    if ($i == $key) {
                        $out[] = $val;
                    }
                } else {
                    $out[] = $first . ':' . $last;
                    if (($i == $key) && ($last != $val)) {
                        $out[] = $val;
                    }
                }
                $first = $last = $val;
            }
        }

        return empty($out)
            ? $first
            : implode(',', $out);
    }
protected function _toSequenceString ( $ sort = true ) { if ( empty ( $ this -> _ids ) ) { return '' ; } $ in = $ this -> _ids ; if ( $ sort && ! $ this -> _sorted ) { $ this -> _sort ( $ in ) ; } $ first = $ last = array_shift ( $ in ) ; $ i = count ( $ in ) - 1 ; $ out = array ( ) ; foreach ( $ in as $ key => $ val ) { if ( ( $ last + 1 ) == $ val ) { $ last = $ val ; } if ( ( $ i == $ key ) || ( $ last != $ val ) ) { if ( $ last == $ first ) { $ out [ ] = $ first ; if ( $ i == $ key ) { $ out [ ] = $ val ; } } else { $ out [ ] = $ first . ':' . $ last ; if ( ( $ i == $ key ) && ( $ last != $ val ) ) { $ out [ ] = $ val ; } } $ first = $ last = $ val ; } } return empty ( $ out ) ? $ first : implode ( ',' , $ out ) ; }
Create an IMAP message sequence string from a list of indices.

Index Format: range_start:range_end,uid,uid2,...

@param boolean $sort  Numerically sort the IDs before creating the
range?

@return string  The IMAP message sequence string.
Create an IMAP message sequence string from a list of indices .