Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html
css
php
web development
communitycreator

What is the PHP Ds\Set remove() function?

Saad Akbar

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Ds\Set remove() is an in-built function used to remove one or more particular values from a set instance.

Syntax


void public Ds\Set::remove ([ mixed $...values ])

Parameters

This function takes in a list of values to be removed from the set.


Commas separate these values.

Return value

No value is returned from this function.

Code

The following code shows the values of the set before and after using remove():

<?php
$set = new \Ds\Set(["PHP", "from", "Educative"]);
echo "Set before removal of values:\n";
print_r($set);
// Remove
$set->remove("PHP","from");
echo "\nSet after removal of values: \n";
print_r($set);
?>

Explanation

"PHP" and "from" are passed into the parameters of remove(). After this, "Educative" is the only value remaining in the set and is displayed when the set values are printed after remove().

Output


Set before removal of values:
Ds\Set Object
(
    [0] => PHP
    [1] => from
    [2] => Educative
)

Set after removal of values:
Ds\Set Object
(
    [0] => Educative
)

RELATED TAGS

html
css
php
web development
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring