note 115755 added to function.reset
| From: | gardnerjohng at gmail dot com | Date: | Thu, 18 Sep 2014 05:54:26 +0000 |
| Subject: | note 115755 added to function.reset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200475@lists.php.net to get a copy of this message | ||
If you need an easy way to retrieve the first *key* in an array (instead of the value), it can be
done like this:
<?php
$properties = array(
'colour' => 'grey',
'flavour' => 'rubber',
'name' => 'Mouse Ball',
'texture' => 'rubbery'
);
# Will output "colour".
echo reset(array_keys($properties));
?>
Potentially helpful for configuration files that define a sequence of items as an associative array.
----
Server IP: 72.52.91.14
Probable Submitter: 180.94.117.172
----
Manual Page -- http://php.net/manual/en/function.reset.php
Edit -- https://master.php.net/note/edit/115755
Del: integrated -- https://master.php.net/note/delete/115755/integrated
Del: useless -- https://master.php.net/note/delete/115755/useless
Del: bad code -- https://master.php.net/note/delete/115755/bad+code
Del: spam -- https://master.php.net/note/delete/115755/spam
Del: non-english -- https://master.php.net/note/delete/115755/non-english
Del: in docs -- https://master.php.net/note/delete/115755/in+docs
Del: other reasons-- https://master.php.net/note/delete/115755
Reject -- https://master.php.net/note/reject/115755
Search -- https://master.php.net/manage/user-notes.php