| 1 |
<?php |
| 2 |
/** |
| 3 |
* Authorizer |
| 4 |
* |
| 5 |
* @license GPL-2.0+ |
| 6 |
* @link https://github.com/uhm-coe/authorizer |
| 7 |
* @package authorizer |
| 8 |
*/ |
| 9 |
|
| 10 |
// Prevent direct access. |
| 11 |
defined( 'ABSPATH' ) || exit; |
| 12 |
|
| 13 |
if ( ! function_exists( 'array_key_last' ) ) { |
| 14 |
/** |
| 15 |
* Polyfill for array_key_last(), used in class-cas.php. Not available in PHP |
| 16 |
* versions below 7.3. |
| 17 |
* |
| 18 |
* Get the last key of the given array without affecting the internal array |
| 19 |
* pointer. |
| 20 |
* |
| 21 |
* @param array $arr An array. |
| 22 |
* |
| 23 |
* @return mixed The last key of array if the array is not empty; NULL otherwise. |
| 24 |
*/ |
| 25 |
function array_key_last( $arr ) { |
| 26 |
$key = null; |
| 27 |
if ( is_array( $arr ) ) { |
| 28 |
end( $arr ); |
| 29 |
$key = key( $arr ); |
| 30 |
} |
| 31 |
|
| 32 |
return $key; |
| 33 |
} |
| 34 |
} |
| 35 |
|