Q:

Write a PHP program to mutate the original array to filter out the values specified

0

Write a PHP program to mutate the original array to filter out the values specified

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
//Licence: https://bit.ly/2CFA5XY
function pull(&$items, ...$params)
{
    $items = array_values(array_diff($items, $params));
    return $items;
}
$items = ['a', 'b', 'c', 'a', 'b', 'c'];
print_r(pull($items, 'a', 'c')); 

?>

Sample Output:

Array
(
    [0] => b
    [1] => b
)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now