$lista=array(1,2,3,4,5,6,7,8,9);
$listb=array(4,6,8);
$listc=array_intersect($lista,$listb);
$listd=array_diff($lista,$listb);


Op maandag 26 augustus 2002 01:48, schreef Rasmus Lerdorf:
> array_intersect() will give you listC directly.  Just feed it list A and
> B.  Then you can take a copy of listA and do a foreach on the array_keys()
> of listC and unset() them.  Now this copy with the removed elements
> becomes your listD
>
> -Rasmus
>
> On Sun, 25 Aug 2002 [EMAIL PROTECTED] wrote:
> > I have two list one is listA and the other is listB I would
> > like to take the values in listB and compare them with listA if any of
> > them match then I what to create a new list listC and put the values
> > that match in it. If they do not match I want the values to go into
> > listD. I have been messing with this for three days and have not been
> > able to get it to work. I have used foreach statements and array_search
> > but what ever I try I just can't seam to get it. What I need is something
> > like below. Could somebody please help.
> >
> >
> >                                  If LISTB MATCHES LISTA     If NO Match
> > LISTA             LISTB              Make LISTC              Make LISTD
> >
> >
> > test1             test4                 test4                   test1
> > test2             test6                 test6                   test2
> > test3             test8                 test8                   test3
> > test4                                                           test5
> > test5                                                           test7
> > test6                                                           test9
> > test7
> > test8
> > test9
> >
> >
> > --
> > Best regards,
> >  rdkurth                          mailto:[EMAIL PROTECTED]
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to