분류 php

원래의 배열을 변경하여 지정된 값을 필터링

컨텐츠 정보

  • 조회 649 (작성일 )

본문

<?php
function pull(&$items, ...$params)
{
    $items = array_values(array_diff($items, $params));
    return $items;
}
$items = ['a', 'b', 'c', 'a', 'b', 'c'];
pull($items, 'a', 'c'); // $items will be ['b', 'b']
php