Re: Associated arrays

From: Date: Wed, 27 Jun 2001 06:58:13 +0000
Subject: Re: Associated arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55350@lists.php.net to get a copy of this message
> Can someone help me out by explaining how I can programatically rename the > key of an associated array? EG Cat01,Cat02 in the example below. > $cats = array( > "Cat01" => array("lv1" => 1, "lv2" => 1, "lv3" > => 1, "lv4" => 1, "lv5" => > 1 ), > "Cat10" => array("lv1" => 1, "lv2" => 1, "lv3" > => 1, "lv4" => 1, "lv5" => > 1 )); > > How do I reference the name of each category i.e Cat01, Cat02 so that I can > programatically change the name (I need them to be user defineable). This > is part of a security level options setup screen by the way, that is the > lv1-5 are user levels - boolean so that we can allow disallow access to > approriate option/categories. I enclose the script I am trying to build if > you have time to check it out. If you want to change the 'Cat01' key so it will be called, say, 'newname': $cats['newname'] = $cats['Cat01']; unset($cats['Cat01']); If you just want to change a 1 to 0: $cats['Cat01']['lv1'] = 0; -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#55350) next »