CaptainChainsaw Posted July 18, 2008 Share Posted July 18, 2008 Hi all, I'm wanting to store all configurable parts of my website in one file which looks something like this: class conf{ private $_confdata=array("dbhost" => "hostname", "doboptions" => array( 'language' => 'en', 'format' => 'dMY', 'minYear' => 1930, 'maxYear' => 2008 ) ); public function getConfItem($key){ return $this->_confdata[$key]; } } I access single values like so: $conf->getConfItem('key') I want to assign the "doboptions" array to a variable, a bit like: $doboptions = $conf->getConfItem('doboptions'); This doesn't work, it appears that the array assigned to "doboptions" is breaking it. Anyone have any suggestions? Thanks again, CC Link to comment https://forums.phpfreaks.com/topic/115533-solved-array-question/ Share on other sites More sharing options...
JasonLewis Posted July 19, 2008 Share Posted July 19, 2008 Well what does your getConfItem() function look like? Link to comment https://forums.phpfreaks.com/topic/115533-solved-array-question/#findComment-593959 Share on other sites More sharing options...
TempleDMDKrazd Posted July 19, 2008 Share Posted July 19, 2008 $conf = new conf; $doboption = $conf->getConfItem("doboptions"); print_r($doboption); //should print the content of the return array Link to comment https://forums.phpfreaks.com/topic/115533-solved-array-question/#findComment-594042 Share on other sites More sharing options...
arifsor Posted July 19, 2008 Share Posted July 19, 2008 your mension script is working properly! whats the error you getting Link to comment https://forums.phpfreaks.com/topic/115533-solved-array-question/#findComment-594100 Share on other sites More sharing options...
CaptainChainsaw Posted July 19, 2008 Author Share Posted July 19, 2008 ok, problem solved ....... I was missing a comma in the conf class *sigh*. Thanks for all your posts! CC Link to comment https://forums.phpfreaks.com/topic/115533-solved-array-question/#findComment-594226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.