note 124451 deleted from function.array-key-first by cmb
| From: | cmb@php.net | Date: | Fri, 29 Nov 2019 12:15:18 +0000 |
| Subject: | note 124451 deleted from function.array-key-first by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213279@lists.php.net to get a copy of this message | ||
Note Submitter: darius
----
Another way to get it:
<?php
$array = [5 => 'x', 10 => 'y', 15 => 'z'];
$the1stKey = array_keys($array)[0];
echo $the1stKey;
?>
Will trigger warning if the $array is empty or if we pass a string or something else...