Skip to content

Commit 747acce

Browse files
pierredupnicolas-grekas
authored andcommitted
PHP 7.3: Add array_key_first and array_key_last functions
1 parent dd09a6b commit 747acce

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

bootstrap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@ function is_countable($var) { return is_array($var) || $var instanceof Countable
2020
p\Php73::$startAt = (int) microtime(true);
2121
function hrtime($asNum = false) { return p\Php73::hrtime($asNum); }
2222
}
23+
24+
if (!function_exists('array_key_first')) {
25+
function array_key_first(array $array) { foreach ($array as $key => $value) { return $key; } }
26+
}
27+
28+
if (!function_exists('array_key_last')) {
29+
function array_key_last(array $array) { $key = null; foreach ($array as $key => $value); return $key; }
30+
}
2331
}

0 commit comments

Comments
 (0)