note 123301 added to function.array-key-first
| From: | mail at vitalyart dot ru | Date: | Fri, 02 Nov 2018 12:00:24 +0000 |
| Subject: | note 123301 added to function.array-key-first | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209587@lists.php.net to get a copy of this message | ||
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)
{
if (count($array)) {
reset($array);
return key($array);
}
return null;
}
}
echo array_key_first([
'foo' => 'value1',
'bar' => 'value2',
]);
// Output: foo
----
Server IP: 208.43.231.9
Probable Submitter: 46.148.202.46
----
Manual Page -- http://php.net/manual/en/function.array-key-first.php
Edit -- https://master.php.net/note/edit/123301
Del: integrated -- https://master.php.net/note/delete/123301/integrated
Del: useless -- https://master.php.net/note/delete/123301/useless
Del: bad code -- https://master.php.net/note/delete/123301/bad+code
Del: spam -- https://master.php.net/note/delete/123301/spam
Del: non-english -- https://master.php.net/note/delete/123301/non-english
Del: in docs -- https://master.php.net/note/delete/123301/in+docs
Del: other reasons-- https://master.php.net/note/delete/123301
Reject -- https://master.php.net/note/reject/123301
Search -- https://master.php.net/manage/user-notes.php