Re: Help with matchng strings
| From: | Richard Lynch | Date: | Mon, 26 Aug 2002 22:59:05 +0000 |
| Subject: | Re: Help with matchng strings | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-114192@lists.php.net to get a copy of this message | ||
>
>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
I think you want these:
$listC = array_intersect($listA, $listB);
$listD = array_difference($listA, $listC);
http://php.net/array_insersect
--
Like Music? http://l-i-e.com/artists.htm