note 118013 added to function.reset

From: Date: Fri, 18 Sep 2015 09:22:14 +0000
Subject: note 118013 added to function.reset
Groups: php.notes 
Request: Send a blank email to php-notes+get-203808@lists.php.net to get a copy of this message
In response to gardnerjohng's note to retrieve the first _key_ of an array: To retrieve the first _key_ of an array you can use the combination of reset() and key(). <?php $properties = array( 'colour' => 'grey', 'flavour' => 'rubber', 'name' => 'Mouse Ball', 'texture' => 'rubbery' ); reset($properties); echo key($properties); // => 'colour' ?> I prefer this solution as you don't have to create the keys array. This should (not measured) improve performance on large arrays. ---- Server IP: 72.52.91.14 Probable Submitter: 178.8.119.228 ---- Manual Page -- http://php.net/manual/en/function.reset.php Edit -- https://master.php.net/note/edit/118013 Del: integrated -- https://master.php.net/note/delete/118013/integrated Del: useless -- https://master.php.net/note/delete/118013/useless Del: bad code -- https://master.php.net/note/delete/118013/bad+code Del: spam -- https://master.php.net/note/delete/118013/spam Del: non-english -- https://master.php.net/note/delete/118013/non-english Del: in docs -- https://master.php.net/note/delete/118013/in+docs Del: other reasons-- https://master.php.net/note/delete/118013 Reject -- https://master.php.net/note/reject/118013 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203808) next »