logo CodeStepByStep logo


Language/Type: PHP collections array

Write a function named remove_all that accepts as a parameter an array of strings along with a second parameter of type string, and returns a new array that is the same as the parameter array but with all occurrences of that string removed.

For example, if an array named $a contains ["a", "b", "c", "b", "b", "a", "b"], the call of remove_all($a, "b") should return ["a", "c", "a"].

Your function should not modify the passed array.

Function: Write a PHP function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.