欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

关于数组处理的问题,急

程序员文章站 2022-05-29 22:56:04
...
$a=array("郑秀文","郭涛","华仔","高圆圆","王子义","郎月婷","刘德华")
$b=array("华仔","刘德华")

用B数组过滤掉$b数组中的重复

输出的效果为:
Array
(
[0] => 郑秀文
[1] => 郭涛
[2] => 高圆圆
[3] => 王子义
[4] => 郎月婷
)


回复讨论(解决方案)

$a = array("郑秀文","郭涛","华仔","高圆圆","王子义","郎月婷","刘德华");$b = array("华仔","刘德华");print_r(array_diff($a, $b));
Array
(
[0] => 郑秀文
[1] => 郭涛
[3] => 高圆圆
[4] => 王子义
[5] => 郎月婷
)
相关标签: 数组