PHP | Ds\Sequence rotate() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Sequence::rotate() function is an inbuilt function in PHP which is used to rotate the sequence element by a given number of rotations. Syntax: void abstract public Ds\Sequence::rotate ( int $rotations ) Parameters: This function accepts single parameter $rotations which holds the number of rotations. Return value: This function does not return any value. Below programs illustrate the Ds\Sequence::rotate() function in PHP: Program 1: php <?php // Create new Sequence $seq = new \Ds\Vector([1, 2, 3, 4, 5]); echo("Original Sequence\n"); // Display the Sequence elements print_r($seq); // Use rotate() function to rotate // the sequence elements $seq->rotate(3); echo("\nSequence after rotating by 3 places\n"); // Display the Sequence elements print_r($seq); ?> Output: Original Sequence Ds\Vector Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Sequence after rotating by 3 places Ds\Vector Object ( [0] => 4 [1] => 5 [2] => 1 [3] => 2 [4] => 3 ) Program 2: php <?php // Create new Sequence $seq = new \Ds\Vector(["Geeks", "for", "Geeks", "Computer", "Science", "Portal"]); echo("Original Sequence\n"); // Display the Sequence elements print_r($seq); // Use rotate() function to rotate // the sequence elements $seq->rotate(8); echo("\nSequence after rotating by 8 places\n"); // Display the Sequence elements print_r($seq); ?> Output: Original Sequence Ds\Vector Object ( [0] => Geeks [1] => for [2] => Geeks [3] => Computer [4] => Science [5] => Portal ) Sequence after rotating by 8 places Ds\Vector Object ( [0] => Geeks [1] => Computer [2] => Science [3] => Portal [4] => Geeks [5] => for ) Reference: https://www.php.net/manual/en/ds-sequence.rotate.php Comment More infoAdvertise with us Next Article PHP | DsMap reverse() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_sequence Similar Reads PHP | DsDeque rotate() Function The Ds\Deque::rotate() function is an inbuilt function in PHP which is used to rotate the elements of Deque by the given number of rotations. Syntax: public Ds\Deque::rotate( $rotations ) : void Parameters: This function accepts single parameter $rotations which holds the number of rotation of the e 2 min read PHP | DsVector rotate() Function The Ds\Vector::rotate() function is an inbuilt function in PHP which is used to rotate the array elements by a given number of rotation. Rotations also happen in-place. Syntax: void public Ds\Vector::rotate( $rotations ) Parameters: This function accepts single parameter $rotations which holds the n 2 min read PHP | DsSequence rotate() Function The Ds\Sequence::rotate() function is an inbuilt function in PHP which is used to rotate the sequence element by a given number of rotations. Syntax: void abstract public Ds\Sequence::rotate ( int $rotations ) Parameters: This function accepts single parameter $rotations which holds the number of ro 2 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 | 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 | DsDeque reverse() Function The Ds\Deque::reverse() function is an inbuilt function in PHP which is used to reverse the elements in the Deque in-place. Syntax: public Ds\Deque::reverse( void ) : void Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below programs i 2 min read PHP | DsMap values() Function The Ds\Map::values() function is an inbuilt function in PHP which is used to return a sequence of the map's values. Syntax: Ds\Sequence public Ds\Map::values ( void ) Parameters: This function does not accepts any parameters. Return Value: It returns a Ds\Sequence containing all the values of the ma 1 min read PHP | DsVector reverse() Function The Ds\Vector::reverse() function is an inbuilt function in PHP which is used to reverse the vector elements in-place. Syntax: void public Ds\Vector::reverse( void ) Parameters: This function does not accepts any parameters. Return Value: This function does not return any value. Below programs illus 2 min read PHP | DsDeque reversed() Function The Ds\Deque::reversed() function is an inbuilt function in PHP which is used to return the copy of Deque which contains the elements in reversed order. Syntax: public Ds\Deque::reversed( void ) : Ds\Deque Parameters: This function does not accept any parameter. Return Value: This function returns a 2 min read PHP | DsDeque slice() Function The Ds\Deque::slice() function is an inbuilt function in PHP which is used to return a sub-Deque which contains elements of the Deque within the index range. Syntax: public Ds\Deque::slice( $index, $length ) : Ds\Deque Parameters: This function accept two parameters as mentioned above and described 2 min read Like