-1

I have 2 arrays

$a = array("1", "2", "3", "4", "5");
$b = array("3", "4", "5", "6", "7");

I want the final result be ("6", "7")

It seems that array_diff() and array_intersect() can't give the result that I need.

Wesley van Opdorp
  • 14,888
  • 4
  • 41
  • 59
Hang
  • 1

1 Answers1

2

Yes, use array_diff, what's your problem?

$arrayA = array("1", "2", "3", "4", "5");
$arrayB = array("3", "4", "5", "6", "7");
$result = array_diff($arrayB, $arrayA);

Docs:

Return Values

Returns an array containing all the entries from array1 that are not present in any of the other arrays.

(codepad example)

knittl
  • 246,190
  • 53
  • 318
  • 364