We can find out difference of two arrays by using array_diff function. This function takes two arrays as input and then returns the result array. Syntax of this function is here.
$new_array = array_diff ($array1, $array2);
For example let us use one array a1 and store text entered by user in a web form after converting the text string to an array. Now to prevent spammers posting URL or posting of some bad words we will develop another array a2 where all negative words we will store. These words we don't want to be present in the first ( a1) array.