Re: changing a key in an array

From: Date: Tue, 21 Jan 2003 14:30:23 +0000
Subject: Re: changing a key in an array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-132404@lists.php.net to get a copy of this message
Jason -- ..and then Jason k Larson said... % % My first question back would be why you create on array with keys you % know you want to change, or why in that case it became necessary to % dereference the original key. A fair question :-) I'm writing a picture gallery add-on which will allow users to create "favorite pictures" baskets. For each basket, the user throws in a bunch of pictures in an array. Then I make an array of baskets, where the name of the basket is the key and the array that is the basket is the value. When a user wants to rename a basket, the new version of that basket appaers at the bottom of the list instead of in its original place -- wherever that was. % % $a['tmp'] =& $a['t']; // exact same values by reference (no copy) I don't think I can do this, since I eventually save the array of arrays to a file for the user to reload on another visit. Thanks, though. % % Only other way I can think of at the moment is to create a copy and % unset the original as you described as brute force. Ah. Well, that's what they get, then :-) % % HTH, % Jason k Larson Thanks & HAND :-D -- David T-G * There is too much animal courage in (play) davidtg@justpickone.org * society and not sufficient moral courage. (work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.general (#132404) next »