Finding out the common / uncommon elements between two Arrays in PHP
- by Veera
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?