note 95318 deleted from function.end by danbrown
| From: | danbrown@php.net | Date: | Sun, 27 Dec 2009 20:10:39 +0000 |
| Subject: | note 95318 deleted from function.end by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164364@lists.php.net to get a copy of this message | ||
Note Submitter: Alexander at example dot com
----
To my previous note:
Sorry to make it probably a bit unclear about reference. I meant function to return value of key and
not reference to key. That means you can change value for this key in your array but not the key
itself.
You can do
<?php
$somelastkey = lastkey($somearray);
$somearray[$somelastkey] = $newvalue;
?>
but you cannot do
<?php
$somelastkey = & lastkey($somearray);
$somelastkey = $newkey;
?>
If you really need to change last key (saving value), you probably should save value for this key,
unset this element and create new one with desired key and saved value.