0

for example I have 2 arrays like the following:

array1 = (2, 3, 4);
array2 = (1, 2, 3, 4, 5);

I want to get the value of the second array, where the value array1 is not found in array2, so we can conclude the following are array3

array3 = (1, 5);

2 Answers 2

5

Diff the arrays

$array3 = array_diff($array2, $array1);
Sign up to request clarification or add additional context in comments.

Comments

1
$array3 = array_diff($array1, $array2);

1 Comment

Explosion Pills's answer is better. -1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.