in reply to Printing and Removing Duplicates in Arrays

Well, after the first match (0 vs 0), $array1size=10; $array2size=3; $count1=0; $count2=0; but @array1=(1,2,3,4,5,6,7,8,9) @array2=(1,4)

You then increase $count1 to 1, and it's now pointing at the value 2, which is why you don't get a match on the value 1.

When the 4s match, another element is deleted from both arrays, but $count1 still increases to try and look at all the original elements (and therefore falls of the end off the shortened array).

--
Tommy
Too stupid to live.
Too stubborn to die.

  • Comment on Re: Printing and Removing Duplicates in Arrays