• PHP Video Tutorials

PHP - Ds Deque remove() Function



Ds\Deque::remove() function can remove and return a value by index.

Syntax

public mixed Ds\Deque::remove( int $index )

Ds\Deque::remove() function can return a value that was removed.

Ds\Deque::remove() function can throw OutOfRangeException if an index is not valid.

Example 1

<?php 
   $deque = new \Ds\Deque([10, 20, 30, 40, 50]); 
   echo("The elements in deque: \n"); 
   print_r($deque); 
   
   echo("\n The element at index 2:"); 
   print_r($deque->remove(2)); 
?>

Example 2

<?php 
   $deque = new \Ds\Deque(["Tutorials", "Point", "India"]); 
   echo("The elements in deque: \n"); 
   print_r($deque); 
   
   echo("\n The element at index 1:"); 
   print_r($deque->remove(1)); 
?>
php_function_reference.htm
Advertisements