PHP Ds\Sequence Functions Complete Reference Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report A Sequence is used to arrange the values in a single and linear dimension way. In some languages, the sequence refers to the List. The sequence is similar to the array which is used as incremental integer keys are listed below: The index value of the sequence are [0, 1, 2, …, size - 1], where size represents the size of the array.The sequence elements are accessed by using index value so it allows to access values by index in the range [0, size - 1].The DS\Sequence is the efficient Data Structure in PHP 7. It is an alternative of the array. Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easiest way to install data structure by using the PECL extension. pecl install ds Syntax: abstract public Ds\Sequence:: Function() Example: Below programs illustrate the Ds\Sequence::capacity() function in PHP: PHP <?php // Declare a sequence $seq = new \Ds\Vector(); // Use capacity() function var_dump($seq->capacity()); // Push element in sequence $seq->push(...range(1, 100)); // Use capacity() function var_dump($seq->capacity()); // Pop element in sequence $seq->pop(); // Use capacity() function var_dump($seq->capacity()); ?> Output: int(8) int(100) int(100) The complete list of data structure DS\SequenceFunctuon is given below: Functions Description allocate() Allocate enough memory for required capacity.apply() Updates all value of sequence by applying a callback Function to each value.capacity() Return the current capacity of sequence.contains() Check the given value exists in the sequence or not.filter() Create new sequence using filter kk.find() Find the value from the sequence. first() Return the first element from the sequence.get() Returns the value at the given index.insert() Insert value in the sequence at the given index.join() Join all values as strings.last() Return the last element from the sequence.map() Returns the result after applying a callback Function to each valuemerge() Returns a sequence after adding all given values to the sequence.pop() Removes the last value from the sequence and returns it.push() Adds values to the end of the sequence.reduce() Reduce the sequence to a single value using a callback Functionremove() Remove and return a value by index.reverse() Reverse the sequence in place.reversed() Return the reverse copy of the sequence element.rotate() Rotate the sequence element by a given number of rotations.set() Updates a value at a given index.shift() Remove the first element from the sequence and return it.slice() Return the subsequence of given range.sort() Sort the sequence element in the same place. sorted() Return the sorted copy of sequence element. sum() Return the sum of all values of the sequence.unshift() Add values to the font of the sequence. Comment More infoAdvertise with us S Sabya_Samadder Follow Improve Article Tags : Web Technologies PHP PHP-ds_sequence Similar Reads PHP DsMap Functions Complete Reference A Map is a sequential collection of key-value pair which is very similar to the array. The key of a map can be of any type and it is unique. If any value added to the same key in a Map then the map value will replace. It is the efficient Data Structure in PHP 7 to provide the alternative of an array 3 min read PHP DOM Functions Complete Reference PHP DOM extension is used to operate on XML documents using DOM API. The DOM extension uses UTF-8 encoding. The Complete list of PHP DOM Functions are listed below: DOMAttr PHP DOMAttr __construct() FunctionPHP DOMAttr isId() Function DOMCdataSection PHP DOMCdataSection __construct() Function DOMCha 2 min read PHP String Functions Complete Reference Strings are a collection of characters. For example, 'G' is the character and 'GeeksforGeeks' is the string. Installation: These functions are not required any installation. These are the part of PHP core. The complete list of PHP string functions are given below: Example: This program helps us to c 6 min read PHP DsQueue Functions Complete Reference A Queue is a linear data structure that follows a particular order in which the operations are performed. The order of queue is First In First Out (FIFO). Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easiest way to install data structure by usi 2 min read PHP DsVector Functions Complete Reference A Vector Data Structure is used to store the sequence of values in a contiguous memory buffer which grows and shrinks automatically. The vector data structure mapped the index value to its index buffer and the growth factor isn't bound to a specific multiple or exponent. It is the efficient Data Str 3 min read PHP DsSequence Functions Complete Reference A Sequence is used to arrange the values in a single and linear dimension way. In some languages, the sequence refers to the List. The sequence is similar to the array which is used as incremental integer keys are listed below: The index value of the sequence are [0, 1, 2, â¦, size - 1], where size r 3 min read Like