note 124007 added to function.array-key-last

From: Date: Wed, 03 Jul 2019 07:17:07 +0000
Subject: note 124007 added to function.array-key-last
Groups: php.notes 
Request: Send a blank email to php-notes+get-211465@lists.php.net to get a copy of this message
Try to beat this polyfill in terms of performance! <?php if( !function_exists('array_key_last') ) { function array_key_last(array $array) { if( !empty($array) ) return key(array_slice($array, -1, 1, true)); } } // Bonus if (!function_exists('array_key_first')) { function array_key_first(array $arr) { foreach($arr as $key => $unused) return $key; } } ?> ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.195 (proxied: 89.28.16.128) ---- Manual Page -- http://php.net/manual/en/function.array-key-last.php Edit -- https://master.php.net/note/edit/124007 Del: integrated -- https://master.php.net/note/delete/124007/integrated Del: useless -- https://master.php.net/note/delete/124007/useless Del: bad code -- https://master.php.net/note/delete/124007/bad+code Del: spam -- https://master.php.net/note/delete/124007/spam Del: non-english -- https://master.php.net/note/delete/124007/non-english Del: in docs -- https://master.php.net/note/delete/124007/in+docs Del: other reasons-- https://master.php.net/note/delete/124007 Reject -- https://master.php.net/note/reject/124007 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#211465) next »