Hello Rasmus,
Ok I understand the array_intersect and have gotten that to work.
I just don't understand the second part using the foreach and unset().
this is what I have it gives me three separate list
$listA="tester1 tester2 tester3 tester4 tester5 tester6 tester7 tester8 tester9";
$listB="tester4 tester6 tester8";
$arraylistA=explode(" ",$listA);
$arraylistB=explode(" ",$listB);
$result = array_intersect ($arraylistA, $arraylistB);
foreach($arraylistA as $valueA){
echo "ValueA: $valueA<br>\n";
}
echo "<br>";
foreach($arraylistB as $valueB){
echo "ValueB: $valueB<br>\n";
}
echo "<br>";
foreach($result as $valueC){
echo "ValueC: $valueC<br>\n";
}
Sunday, August 25, 2002, 4:48:36 PM, you wrote:
RL> array_intersect() will give you listC directly. Just feed it list A and
RL> B. Then you can take a copy of listA and do a foreach on the array_keys()
RL> of listC and unset() them. Now this copy with the removed elements
RL> becomes your listD
RL> -Rasmus
RL> 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
>>
--
Best regards,
rdkurth mailto:[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php