开发者

How to get A-B in PHP?

$arr1=array(23,43,54);
$arr2=array(34,23,3456,43,11,54);

I want to get elements of $arr2 that's not in $arr1开发者_开发百科


array_diff() is your man. http://php.net/manual/en/function.array-diff.php


Take a look at: http://www.php.net/manual/en/function.array-diff.php


Try this:

$new_arr = array_diff($arr2, $arr1);

Hmmm, if that doesn't work, switch $arr1 and $arr2 around.

Manual -> http://php.net/manual/en/function.array-diff.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜