I did some benchmarks. in_array vs preg_replace approaches are almost identical in terms of performance (very fast). Got the simplest implementation with explode, in_array and array_diff.
I've tweaked it a bit, to make it work case insensitive, because theoretically you can write Null or NULL in PHP, and to throw an exception on intersection type.
I did some benchmarks.
in_array
vspreg_replace
approaches are almost identical in terms of performance (very fast). Got the simplest implementation withexplode
,in_array
andarray_diff
.