sandy1028 wrote:Hi,
Two arrays
array_1=array(A,B,C);
arry_2=array(A,A,B,B,A,B,A,😎;
How to find out the element which is not in arry_2.
Here in the above example the element should show as C.
Your code has some issues as is..
Your need to use dollarsigns infront of your array_1 and array_2 variables..
You need to use quotes for the values of the keys inside the arrays..otherwise, you get 'Notice: Use of undefined constant X'
Try:
$array_1 = array('A','B','C');
$array_2 = array('A','A','B','B','A','B','A','B');
$difference = array_diff($array_1, $array_2);
foreach($difference as $valDiff){
echo $valDiff;
}
Cheers,
NRG