Home > Backend Development > PHP Tutorial > 删数组有得有重复值,该如何处理

删数组有得有重复值,该如何处理

WBOY
Release: 2016-06-13 10:04:12
Original
843 people have browsed it

删数组有得有重复值
有原数组a 里有值 $a=array(a,b,c);
比较数组b 里有值 $b=array(b);

两个相比较,得到$c= array(a,c);

请问一下,这个怎么做。

------解决方案--------------------
循环判断或者移除呗
------解决方案--------------------
用array_diff ($array_a,$array_b)
------解决方案--------------------
array_diff ,数组相减
------解决方案--------------------

PHP code
$a = array(a,b,c);$b = array(b);print_r(array_diff($a, $b));<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

用array_diff ($array_a,$array_b)

------解决方案--------------------
http://baike.baidu.com/view/4067743.htm
------解决方案--------------------
其实你的意思就是要找出2个数组的中差集,array_diff()这个系统函数即可
------解决方案--------------------
array_diff()手册里有

------解决方案--------------------
探讨

用array_diff ($array_a,$array_b)

------解决方案--------------------
探讨

用array_diff ($array_a,$array_b)

Related labels:
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