Skip to content
Advertisement

Tag: array-intersect

Array Intersection – only once

Newbie here, so I have a problem with the array_intersect function. I am comparing two arrays with intersection but I get some results twice. For example: 2 arrays $result = array_intersect($array1, $array2); This returns: But I want this: I want this to return apple and orange ONCE each. Currently it returns apple, then orange, and then another orange. Am I

array_uintersect() gives unexpected results when callback only returns 0 or 1

I have a custom callback in my array_uintersect() call because I need to case-sensitively compare strings in two elements while comparing rows between two multi-dimensional arrays. OUTPUT I can’t understand why this code doesn’t produce the correct output which should be an array with “B”, “C” and “D” elements, because only “A” element is different from $vieja to $nueva… if

Advertisement