each number in the first array corresponds to a letter in the 2nd array. how can I get rid of similar terms. For example 6 and r are double. I want to get rid of one pair.
The array_unique function is good if you have dupes in the same array. If you want to compare 2 different arrays, you can do that like this:
<?php
foreach($a as $c)
{foreach($b as $d)
{if($c == $d)
unset($d);}
}
?>
The problem with unset tho...is that it will remove the indices/keys of the array element (unlike the array_unique). For example (these variables are not corresponding to the above code): If $a's index is 0, and $b is 1 (in the first array)....$c is 0 and $d is 1 in the (in the second array)....and $d & $a are dupes in the 2 arrays...you unset $a, it then $a would be gone and $c will remain 1. The indices do not change! - PAINKILLER
aack...last line: you unset $a and then $a would be gone and $b would remain with an index of 1. There would be no 0 in the first array. Ofcourse this just applies to 1 dimensional arrays.
Hope that helped, it's fairly simple. - PAINKILLER
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.