如何过滤数组中的一些数值?(How to filter some numerical values from an array? [duplicate])
这个问题在这里已经有了答案:
两个数组之间的差异 5个答案我有一个数组$myArray1 ,其数值类似于2 5 7 13 23 25另一个数组$myArray2数值类似于3 4 7 11 13 25
我的要求是获得第三个数组$myArray3 ,只有$myArray3值不存在于$myArray2 ie 2 5 23
请告诉我任何PHP的功能?
This question already has an answer here:
difference between two arrays 5 answersI have an array $myArray1 with some numerical values like 2 5 7 13 23 25 Another array $myArray2 has numerical values like 3 4 7 11 13 25
My requirement is to get a third array $myArray3 having only those values of $myArray1 that are not present in $myArray2 i.e. 2 5 23
Please tell me any function of php for this?
最满意答案
$myArray1=[2,5,7,13,23,25]; $myArray2=[3,4,7,11,13,25]; $myArray3=array_diff($myArray1,$myArray2); var_dump($myArray3); // 2, 5, 23 $myArray1=[2,5,7,13,23,25]; $myArray2=[3,4,7,11,13,25]; $myArray3=array_diff($myArray1,$myArray2); var_dump($myArray3); // 2, 5, 23更多推荐
发布评论