From fe39185894cc7c7f1d4d50b15cc96476b35641d9 Mon Sep 17 00:00:00 2001 From: Frederik Ramm Date: Thu, 6 May 2021 20:44:04 +0200 Subject: [PATCH] Add array_key_last function for PHP <7.3 This patch adds an array_key_last function if it doesn't yet exist, fixes #2316. It is tested on PHP 7.2.24 but not PHP 7.3. --- lib-php/lib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib-php/lib.php b/lib-php/lib.php index a1f528fa..8d82c5b3 100644 --- a/lib-php/lib.php +++ b/lib-php/lib.php @@ -227,3 +227,10 @@ function closestHouseNumber($aRow) return max(min($aRow['endnumber'], $iHn), $aRow['startnumber']); } + +if (!function_exists('array_key_last')) { + function array_key_last(array $array) + { + if (!empty($array)) return key(array_slice($array, -1, 1, true)); + } +} -- 2.39.5