Shell and standard Unix utilities are well versed in text files.
In this area, arrays will be text files whose elements are strings.
To find a common part between two such arrays, there is a standard comm command. comm expects a selection in alphabetical order though.
So, if you have two files A and B containing the elements of these two arrays, one per line (which also means that the elements of the array cannot contain newlines), you can find the intersection with
comm -12 <(sort A) <(sort B)
If you want to start with bash arrays (but using arrays in shells is usually a good indicator that you are using the wrong tool for your task), you can convert back and forth between bash arrays and our text string arrays with printf '%s\n' and word splitting:
array_one=(20 30 40 50) array_two=(10 20 30 80 100 110 40) IFS=$'\n'; set -f intersection=($(comm -12 <( printf '%s\n' "${array_one[@]}" | sort) <( printf '%s\n' "${array_two[@]}" | sort)))
source share