如何比较数组的元素

时间:2016-08-05 11:00:30

标签: php

我试图从mysql数据库中获取W/Bitmap: Called getWidth() on a recycle()'d bitmap! This is undefined behavior! W/Bitmap: Called getHeight() on a recycle()'d bitmap! This is undefined behavior! W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior! W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior! W/Bitmap: Called hasAlpha() on a recycle()'d bitmap! This is undefined behavior! java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@d5316ab ,mysql查询的输出如下所示

leave_dates

这是代码:

08/01/2016, 08/02/201608/16/2016, 08/17/2016, 08/18/2016, 08/19/2016, 08/20/2016, 08/21/2016, 08/22/2016, 08/23/2016

问题是我没有得到我想要的结果我想要比较这两个数组的元素并显示任何diff元素(如果存在)。

2 个答案:

答案 0 :(得分:0)

做这个简单的解决方案,尝试将数组添加到那里演示数组变量..

 $array1 = array(10, 15, 20, 25);
    $array2 = array(10, 15, 100, 150);
    $output = array_merge(array_diff($array1, $array2), array_diff($array2, $array1));


    // $output will be (20, 25, 100, 150);

答案 1 :(得分:0)

array_diff只能以一种方式工作,为您提供第一个数组中不存在于另一个数组中的项目。

$result = array_merge(array_diff($dat, $input_array), array_diff($input_array, $dat));