Instead of using foreach, in_array and array_column has been used. Looping in more than thousands element, it would be better to find specific element.
in_array
array_column