For some reason, this doesnt work. Can someone look at it with fresh eyes and tell me what im doing wrong.
I want to add two arrays and eliminate all duplicates.
an example, array1="a, b, c, d"
array2="a, b, e, f"
Then
Addarray="a, b, c, d, e, f"
here is my code. The add part works, but I continue to get the dupes.
//====================================================
//========= Compile Arrays into One =========
//====================================================
function compilelist($list1, $list2) {
$numlist1 = count($list1);
$numlist2 = count($list2);
$x = 1;
$y = 1;
$counter = $numlist2+1;
$compiled = $list2;
while ($x <= $numlist1) {
while ($y <= $numlist2) {
if ($list1[$x] == $list2[$y]) {
$add = "no"; }
$y = $y + 1;
}
$y = 1;
if (!$add) {
$compiled[$counter] = $list1[$x];
$counter = $counter + 1;
unset ($add); }
$x = $x + 1;
}
return ($compiled);
} // End of Compile List Func
I want to add two arrays and eliminate all duplicates.
an example, array1="a, b, c, d"
array2="a, b, e, f"
Then
Addarray="a, b, c, d, e, f"
here is my code. The add part works, but I continue to get the dupes.
//====================================================
//========= Compile Arrays into One =========
//====================================================
function compilelist($list1, $list2) {
$numlist1 = count($list1);
$numlist2 = count($list2);
$x = 1;
$y = 1;
$counter = $numlist2+1;
$compiled = $list2;
while ($x <= $numlist1) {
while ($y <= $numlist2) {
if ($list1[$x] == $list2[$y]) {
$add = "no"; }
$y = $y + 1;
}
$y = 1;
if (!$add) {
$compiled[$counter] = $list1[$x];
$counter = $counter + 1;
unset ($add); }
$x = $x + 1;
}
return ($compiled);
} // End of Compile List Func