<?php

$needle = array(1,1); 
$haystack1 = array(0,1,0,0,0,1,1,0,1,0); 
$haystack2 = array(0,0,0,0,1,0,1,0,0,1); 

echo "needle ".(subarray_exists($needle, $haystack1) ? "exists" : "does not exist")." in haystack1\n";
echo "needle ".(subarray_exists($needle, $haystack2) ? "exists" : "does not exist")." in haystack2\n";


function subarray_exists(array $needle, array $haystack) {
    if (count($needle) > count($haystack)) {
        return false;
    }

    $needle = array_values($needle);
    $iterations = count($haystack) - count($needle) + 1;
    for ($i = 0; $i < $iterations; ++$i) {
        if (array_slice($haystack, $i, count($needle)) == $needle) {
            return true;
        }
    }

    return false;
}