note 123503 deleted from function.array-key-first by cmb
| From: | cmb@php.net | Date: | Wed, 08 May 2019 09:50:25 +0000 |
| Subject: | note 123503 deleted from function.array-key-first by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210989@lists.php.net to get a copy of this message | ||
Note Submitter: mirko dot pagliai at gmail dot com
----
It's much simpler than the examples already posted by other users (without ridiculous foreach
cycles, LoL).
For PHP < 7.3.0:
<?php
if (!function_exists('array_key_first')) {
/**
* Gets the first key of an array
*
* @param array $array
* @return mixed
*/
function array_key_first(array $array)
{
return $array ? array_keys($array)[0] : null;
}