cgm225 Posted May 23, 2008 Share Posted May 23, 2008 I am creating a new method in which I pass a $registryItems variable that is an array, all as follow public function setRegistryArray($registryItems) { //$registryItems is an array() } Within that method, I want to use the following existing method so I can add the $registryItems array values to the registry: //Sets registry variable public function set($label, $object) { $this->store[$label] = $object; } However, I am uncertain how to do this. Thank you in advance! Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted May 23, 2008 Share Posted May 23, 2008 You can use a foreach loop to cycle through the array calling the registry set multiple times. Quote Link to comment Share on other sites More sharing options...
cgm225 Posted May 23, 2008 Author Share Posted May 23, 2008 I tried that and was having trouble with the logic.. could you give me some sample code? Quote Link to comment Share on other sites More sharing options...
cgm225 Posted May 23, 2008 Author Share Posted May 23, 2008 Like this? public function setRegistryArray($registryItems) { foreach ($registryItems as $key => $value) { $this->set($key, $value); } } Quote Link to comment Share on other sites More sharing options...
jonsjava Posted May 23, 2008 Share Posted May 23, 2008 that looks about right. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.