Last active
November 9, 2019 19:27
-
-
Save hyperized/1ac93a5a08fd46523315fc2a7983086f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public static function isUpperBoundary(array $input, int $current_key, $pattern, int $steps_back): bool | |
{ | |
for ($counter = $current_key - 1; $counter >= $current_key - $steps_back; $counter--) { | |
if (!array_key_exists($counter, $input) || $input[$counter] !== $pattern) { | |
return false; | |
} | |
} | |
return true; | |
} | |
public static function isLowerBoundary(array $input, int $current_key, $pattern, int $steps_forward): bool | |
{ | |
for ($counter = $current_key + 1; $counter <= $current_key + $steps_forward; $counter++) { | |
if (!array_key_exists($counter, $input) || $input[$counter] !== $pattern) { | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment