I have 2 arrays, Array A and B respectively . Array A contains ~300,000 string records, e.g.
[0] => 'apple',
[1] => 'pineapple',
[2] => 'orange',
...
[299,999] => 'banana'
while Array B contains 100,000 string values, e.g.
[0] => 'bamboo',
[1] => 'banana',
[2] => 'boy',
[3] => 'ball',
[4] => 'balloon',
[5] => 'bazooka',
The question is, how to find out the common values between 2 arrays ?
array_intersect() seems a promising function, but I worry about the performance. Is it better to convert the 2 arrays into text file, and do file-based compare? or am I worrying too much?
Codes to use array_intersect()
:
$result_array = array_intersect($arrayA, $arrayB);