Better way to unset multiple array elements

后端 未结 4 2094
说谎
说谎 2020-12-07 13:29

The deal here is that I have an array with 17 elements. I want to get the elements I need for a certain time and remove them permanently from the array.

Here\'s the

4条回答
  •  粉色の甜心
    2020-12-07 13:47

    Use array_diff_key to remove

    $remove = ['telephone', 'country'];
    
    array_diff_key($post, array_flip($remove));
    

    You could use array_intersect_key if you wanted to supply an array of keys to keep.

提交回复
热议问题