Home > Backend Development > PHP Tutorial > 求个高性能的删除数组元素的函数

求个高性能的删除数组元素的函数

WBOY
Release: 2016-06-23 14:16:47
Original
989 people have browsed it


$array_a = array(1,2,3,4,5...3000); //约3000个元素

$array_b = array(1,100,200,300,500,1000,2000,3000);

在 $array_a 中找出 $array_b 的全部元素,并删除。

例如:

$key = array_search(200,$array_a);

unset($array_a[$key]);

怎么写才能性能最高。


回复讨论(解决方案)

print_r(array_diff($array_a,$array_b));

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template