“Array to string conversion error” when calling array_diff_assoc() with a multidimensional array

According to it: php -r ‘array_diff(array(“a” => array(“b” => 4)), array(1));’ PHP Notice: Array to string conversion in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. array_diff() Command line code:1 One of your arrays is multidimensional. array_diff only checks one dimension of a n-dimensional array. Of … Read more

How to get the difference between two arrays in JavaScript?

There is a better way using ES7: Intersection let intersection = arr1.filter(x => arr2.includes(x)); For [1,2,3] [2,3] it will yield [2,3]. On the other hand, for [1,2,3] [2,3,5] will return the same thing. Difference let difference = arr1.filter(x => !arr2.includes(x)); For [1,2,3] [2,3] it will yield [1]. On the other hand, for [1,2,3] [2,3,5] will … Read more