Crew-Portal Posted August 21, 2009 Share Posted August 21, 2009 <?php $config= array('site'=> array('connection'=> array('database'=>'SECRET', 'username'=>'SECRET', 'password'=>'SECRET', 'location'=>'localhost'), array('settings'=> array('backgroundcolor'=>'#CEE1E9', 'contentcolor'=>'#FFFFFF', 'sidebarcolor'=>'#C8D1D5', 'textcolor'=>'#000000', 'linkcolor'=>'#002E6E', 'backgroundimage'=>null, 'disposition'=>1), ), array('name'=> array('sitename'=>'None', 'slogan'=>'None', 'language'=>'English'), ), array('sessions'=> array('username'=>$_SESSION['valid_user'], 'user_id'=>$_SESSION['user_id']), ), ) ) ;?> Why cant I access my arrays like.. $config['site']['settings']['backgroundcolor']; I cant figure it out. And im not getting any errors.. Link to comment https://forums.phpfreaks.com/topic/171272-solved-3d-arrays-hate-me/ Share on other sites More sharing options...
trq Posted August 21, 2009 Share Posted August 21, 2009 Some consistent indentation would likely help you. Link to comment https://forums.phpfreaks.com/topic/171272-solved-3d-arrays-hate-me/#findComment-903152 Share on other sites More sharing options...
trq Posted August 21, 2009 Share Posted August 21, 2009 Try print_r($config) to see what you've got. Looks to me like 'settings' is within 'connection'. Link to comment https://forums.phpfreaks.com/topic/171272-solved-3d-arrays-hate-me/#findComment-903153 Share on other sites More sharing options...
Crew-Portal Posted August 21, 2009 Author Share Posted August 21, 2009 I surrounded the array with <PRE></PRE> and got: Array ( [site] => Array ( [connection] => Array ( [database] => SECRET [username] => SECRET [password] => SECRET [location] => localhost ) [0] => Array ( [settings] => Array ( [backgroundcolor] => #CEE1E9 [contentcolor] => #FFFFFF [sidebarcolor] => #C8D1D5 [textcolor] => #000000 [linkcolor] => #002E6E [backgroundimage] => [disposition] => 1 ) ) [1] => Array ( [name] => Array ( [sitename] => None [slogan] => None [language] => English ) ) [2] => Array ( [sessions] => Array ( [username] => [user_id] => ) ) ) ) Does that shed any light on the situation? Cause I understand that I dont have the arrays grouped properly. But sadly I dont know how to fix it :'( Link to comment https://forums.phpfreaks.com/topic/171272-solved-3d-arrays-hate-me/#findComment-903155 Share on other sites More sharing options...
Garethp Posted August 21, 2009 Share Posted August 21, 2009 You forgot to close your connection array Link to comment https://forums.phpfreaks.com/topic/171272-solved-3d-arrays-hate-me/#findComment-903160 Share on other sites More sharing options...
Crew-Portal Posted August 21, 2009 Author Share Posted August 21, 2009 Thanks, That wasnt the problem but I got it solved myself. How I did it.. I still dont know.. But it works now, thats all I care about Link to comment https://forums.phpfreaks.com/topic/171272-solved-3d-arrays-hate-me/#findComment-903161 Share on other sites More sharing options...
Garethp Posted August 21, 2009 Share Posted August 21, 2009 Besides, shouldn't it be $Config = array( 'connection'=> array(Stuff), 'Settings'=>array(Stuff), 'Name'=>array(Stuff) ); ? Link to comment https://forums.phpfreaks.com/topic/171272-solved-3d-arrays-hate-me/#findComment-903164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.