This does what you ask for, it is somewhat specific, since all arrays must be unblocked and have unique values.
In addition, in this version, arrays can contain only integer or string values. If you need any NULL, object, float and arrays, part of it should be changed from array_flip() + isset() to array_search() .
CodePad / Gist
The relevant part is to compare the fragment of the array you are looking for (here $in ), with the array you are looking for (here $for ):
array_slice($in, $pos, $len) === $for
$pos was scanned earlier for the first value of $for , $len is count($for) .
source share