开发者

How to get A-B in PHP?

开发者 https://www.devze.com 2022-12-18 00:15 出处:网络
$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
$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

精彩评论

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