Home > Backend Development > PHP Tutorial > array_udiff的不解

array_udiff的不解

WBOY
Release: 2016-06-13 12:30:12
Original
1439 people have browsed it

array_udiff的困惑
今天看书,书中有一个例子用到了array_udiff,查了下手册,经过测试,还是对其一知半解.

$a = array(1,2,3,4,5);<br />
$b = array(1,6,3,4,5);<br />
echo "<pre class="brush:php;toolbar:false">";<br />
print_r(array_udiff($a,$b,function($a,$b){<br />
	return ($a === $b)? 0:1;<br />
}));
Copy after login

我希望的得到的结果:
Array<br />
(<br />
    [0] => 2<br />
)
Copy after login

实际结果
Array<br />
(<br />
    [0] => 1<br />
    [1] => 2<br />
    [2] => 3<br />
    [4] => 5<br />
)
Copy after login

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