Created
March 17, 2017 22:46
-
-
Save srph/2d4f7a353ca60e24b3371389e56b7c4d to your computer and use it in GitHub Desktop.
PHP: array_find_index
This file contains hidden or 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 | |
| function array_find_index(array $array, Closure $callback) { | |
| for ($i = 0; $i < count($array); $i++) { | |
| if ($callback($array[$i], $i)) { | |
| return $i; | |
| } | |
| } | |
| return -1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment