• PHP Video Tutorials

PHP - Ds Map remove() Function


Advertisements

Ds\Map::remove() function can remove and return a value by key.

Syntax

public mixed Ds\Map::remove( mixed $key [, mixed $default ] )

Ds\Map::remove() function can remove and return a value by key or return an optional default value if a key can't be found.

Ds\Map::remove() function can return a value that was removed or a default value if provided, and a key can't be found in a map.

Ds\Map::remove() function can throw OutOfBoundsException if a key can't be found, and a default value was not provided.

Example 1

<?php  
   $map = new \Ds\Map([1 => "Tutorials", 2 => "Point", 3 => "India", 4 => "Tutorix"]);  
  
   echo("The map elements are: \n");  
   print_r($map);  
  
   echo("\n The removed element of a map: \n");  
   var_dump($map->remove(3));  
?>

Example 2

<?php  
   $map = new \Ds\Map(["a" => "Tutorials", "b" => "Point", "c" => "India", "d" => "Tutorix"]);  
  
   echo("The map elements are: \n");  
   print_r($map);  
  
   echo("\n The removed element of a map: \n");  
   var_dump($map->remove("c"));  
?>
php_function_reference.htm

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements