Log in

View Full Version : logic question



awakener1986
01-22-2010, 12:36 PM
hi i have a question regarding some logic.

well lets say we have 2 arrays.

arr1 = array('orange','apple','banana','grapes');
arr2 = array('orange','banana','grapes');

i want to create a loop to compare these two arrays and to determine the differences between this two arrays. for this case it would be the 'apple' which is the odd 1.

any help would be appreciated. thanks

Nile
01-22-2010, 01:12 PM
You can try array_search() and array_shift().

siddesh
06-26-2013, 07:34 AM
$newarray=array_diff($arr1,$arr2);
print_r($newarray);