Finding out the common / uncommon elements between two Arrays in PHP

Posted by Veera on Stack Overflow See other posts from Stack Overflow or by Veera
Published on 2010-04-07T06:36:35Z Indexed on 2010/04/07 6:43 UTC
Read the original article Hit count: 261

Filed under:
|

Consider I have two arrays:

$friends = Array('foo', 'bar', 'alpha');
$attendees = Array('foo', 'bar');

Now I need to populate a new array $nonattendees which contains only the elements which are in $friends array and not in $attendees array. i.e, $nonattendees array should be populated with 'alpha'.

Is there any in built array operation available in PHP to achieve the above functionality or should I write my own for loops?

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays