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! Link to comment https://forums.phpfreaks.com/topic/106950-help-using-one-method-within-another/ 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. Link to comment https://forums.phpfreaks.com/topic/106950-help-using-one-method-within-another/#findComment-548183 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? Link to comment https://forums.phpfreaks.com/topic/106950-help-using-one-method-within-another/#findComment-548227 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); } } Link to comment https://forums.phpfreaks.com/topic/106950-help-using-one-method-within-another/#findComment-548230 Share on other sites More sharing options...
jonsjava Posted May 23, 2008 Share Posted May 23, 2008 that looks about right. Link to comment https://forums.phpfreaks.com/topic/106950-help-using-one-method-within-another/#findComment-548235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.