PHP | Ds\Sequence insert() Function Last Updated : 21 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Sequence::insert() function is an inbuilt function in PHP which is used to insert value in the sequence at the given index. Syntax: void abstract public Ds\Sequence::insert ( int $index [, mixed $...values ] ) Parameter: This function accepts two parameter as mentioned above and described below: $index: This parameter hold the index value where element inserted. Its value lies between 0 <= $index <= count. Where count indicate number of element in the sequence. $values: This parameter hold the value which to be inserted. Return value: This function does not return any values. Below programs illustrate the Ds\Sequence::insert() function in PHP: Program 1: php <?php // Create new sequence $seq = new \Ds\Vector(); // Use insert() function $seq->insert(0, "g"); // Use insert() function $seq->insert(1, "e"); // Use insert() function $seq->insert(2, "e"); // Use insert() function $seq->insert(3, "k"); // Use insert() function $seq->insert(4, "s"); // Use insert() function $seq->insert(5, 4); var_dump($seq); ?> Output: object(Ds\Vector)#1 (6) { [0] => string(1) "g" [1] => string(1) "e" [2] => string(1) "e" [3] => string(1) "k" [4] => string(1) "s" [5] => int(4) } Program 2: php <?php // Create new sequence $seq = new \Ds\Vector(); // Use insert() function to insert // element in the sequence $seq->insert(0, 1, 2, 3, 4, 5, ["g", "e", "e", "k", 1, 2]); var_dump($seq); ?> Output: object(Ds\Vector)#1 (6) { [0] => int(1) [1] => int(2) [2] => int(3) [3] => int(4) [4] => int(5) [5] => array(6) { [0] => string(1) "g" [1] => string(1) "e" [2] => string(1) "e" [3] => string(1) "k" [4] => int(1) [5] => int(2) } } Reference: http://php.net/manual/en/ds-sequence.insert.php Comment More infoAdvertise with us Next Article PHP | DsSet last() Function V vijay_raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DS\Collection Similar Reads PHP | DsDeque insert() Function The Ds\Deque::insert() function is an inbuilt function in PHP which is used to insert the value at the given index in the Deque. Syntax: public Ds\Deque::insert( $index, $values ) : void Parameters: This function accepts two parameter as mentioned above and described below: $index: This parameter ho 2 min read PHP SplHeap insert() Function The SplHeap::insert() function is an inbuilt function in PHP which is used to insert an element in the heap by sifting it up. Generally, the Heap Data Structure are of two types: Max-Heap: In a Max-Heap the key present at the root node must be greatest among the keys present at all of its children. 2 min read PHP | DsVector insert() Function The Ds\Vector::insert() function is an inbuilt function in PHP which is used to insert the element into the vector at the given index. Syntax: void public Ds\Vector::insert( $index, $values ) Parameters: This function accepts two parameter as mentioned above and described below: $index: This paramet 2 min read PHP SplPriorityQueue insert() Function The SplPriorityQueue::insert() function is an inbuilt function in PHP which is used to inserts an element in the queue by sifting the elements. Insert elements in priority queue by given priority. Syntax: bool SplPriorityQueue::insert( mixed $value, mixed $priority ) Parameters: This function accept 2 min read PHP | DsSequence insert() Function The Ds\Sequence::insert() function is an inbuilt function in PHP which is used to insert value in the sequence at the given index. Syntax: void abstract public Ds\Sequence::insert ( int $index [, mixed $...values ] ) Parameter: This function accepts two parameter as mentioned above and described bel 2 min read PHP | DsSet last() Function The Ds\Set::last() function is an inbuilt function in PHP which is used to return the last element from the Set instance. Syntax: void public Ds\Set::last( void ) Parameter: This function does not accept any parameter. Return Value: This function returns the last value of the Set. Below programs ill 1 min read PHP | DsMap reverse() Function The Ds/Map::reverse() function in PHP is used to in-place reverse the elements of a specified Map instance. That is, the function in-place reverses the order of elements present in the specified Map instance. Syntax: Ds\Map public Ds\Map::reverse ( int $position ) Parameter: This function does not a 2 min read PHP next() Function The next() function is an inbuilt function in PHP and does the following operations: It is used to return the value of the next element in an array which the internal pointer is currently pointing to. We can know the current element by current function. The next() function increments the internal po 2 min read PHP | DsSequence reduce() Function The Ds\Sequence::reduce() function is an inbuilt function in PHP which is used to reduce the sequence to a single value using a callback function. Syntax: mixed abstract public Ds\Sequence::reduce ( callable $callback [, mixed $initial ] ) Parameters: This function accepts two parameters as mentione 2 min read PHP DsSet reversed() Function The Ds\Set::reversed() function of Ds\Set class in PHP is an inbuilt function which is used to create a copy of the original Set with values arranged in reverse order. That is, this function returns a reversed copy of the actual set. This function does not affect the original set instance. Syntax: D 2 min read Like