0

Hi i would like to filter array in php. for example

$a = ARRAY('a', 'b', 'c', 'd', 'e');
$b = ARRAY('c', 'd');

$a will be filtered by values in array $b

and result is ['a', 'b', 'e']

may I know how to do it in php?

Thank you.

flag

2 Answers

7

Hello,

try array_diff();

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

Regards, Gabriel

link|flag
3
$result = array_diff($a, $b)
link|flag

Your Answer

get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.