sandy1028 Posted June 30, 2008 Share Posted June 30, 2008 Hi, Two arrays array_1=array(A,B,C); arry_2=array(A,A,B,B,A,B,A,B); How to find out the element which is not in arry_2. Here in the above example the element should show as C. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted June 30, 2008 Share Posted June 30, 2008 Here's one way using the array_unique() and the array_diff() functions: <?php $array_1=array('A','B','C'); $array_2=array('A','A','B','B','A','B','A','B'); $array_3 = array_diff($array_1,array_unique($array_2)); echo '<pre>' . print_r($array_3,true) . '</pre>'; ?> Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.