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

  • برمجة بي اتش بي

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

الأجوبة

<?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
)
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...