Write a function named remove_range
that accepts an array of numbers and two integer
values and $max
as parameters and removes
all elements values in the range $min
through $max
(inclusive).
For example, if an array named $arr
stores [7, 9, 4, 2.4, 7, 7, 5.5, 3, 5, 1, 7, 8, 6, 7]
,
the call of remove_range($arr, 5, 7)
should change the array to store [9, 4, 2.4, 3, 1, 8]
.
You may assume the array passed is non-null and contains only numbers. If the passed $min
is greater than
the passed $max
, your function should throw an Exception
with the message, "Error: min must be less than or equal to max".
A note about references in PHP: In order to write a function passes a parameter as
reference (thus modifying its state), you'll need to prepend "&" to the variable declaration
in the function header. For example, a function foo
that modifies the state
of an array parameter may be defined as:
function foo(&$arr) { ... }