• PHP Video Tutorials

PHP - Ds Sequence rotate() Function



Ds\Sequence::rotate() function can rotate the sequence by given number of rotations.

Syntax

public abstract void Ds\Sequence::rotate( int $rotations )

Ds\Sequence::rotate() function doesn't return any value, and a sequence of the current instance can be rotated.

Example 1

<?php  
   $seq = new \Ds\Vector([1, 2, 3, 4, 5]);  
  
   echo("The original sequence: \n");  
   print_r($seq);  
  
   $seq->rotate(3);  
   echo("\n The sequence after rotating by 3 places: \n");  
   print_r($seq);  
?>

Example-2

<?php  
   $seq = new \Ds\Vector(["Raja", "Adithya", "Jai", "Chaitanya", "Surya", "Ravi"]);  
   
   echo("The original sequence: \n");  
   print_r($seq);  
   
   $seq->rotate(8);  
   echo("\n The sequence after rotating by 8 places: \n");  
   print_r($seq);
?> 
php_function_reference.htm
Advertisements