0

I would like to filter an array.

$a = ['a', 'b', 'c', 'd', 'e'];
$b = ['c', 'd'];

$a will be filtered by values in array $b and the result should be:

['a', 'b', 'e']

2 Answers 2

9

Try array_diff();

PHP Documentation: http://php.net/manual/en/function.array-diff.php

Sign up to request clarification or add additional context in comments.

Comments

3
$result = array_diff($a, $b)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.