The function will return the difference of one array. You can do:
$array1 = array();
$array2 = array();
$diff1 = array_diff($array1, $array2);
$diff2 = array_diff($array2, $array1);
$diff = array_merge($diff1, $diff2);
$diff = array_unique($diff);
print_r($diff);
Which would work the diff both ways, then merge them together and then remove the duplicates.
How can i extract the elements that exist in the first array and not in the second array.
This question is exactly what the [man]array_diff/man function does. Given two arrays, it will return those that are in the first array, that aren't in the second (or any other arrays passed). So it would seem it does exactly what you want... get the names from $array1 that aren't present in the second array.