php - text1/text2 to array['text1']['text2']? -


i'm trying make like

function config( $string ){     require 'configuration.php';     return $config[$string]; } 

but have problem when config has 2d array. like:

$config['features'] = array(         'memcached' => true,         'compress'  => true,         'gzip'      => true ); 

how can config('features/memcached') or if can have 3 or more threaded array config('features/memcached/version14/etc') ( example ) return true still works when config('features') returns array function above. ideas ?

just split string keys:

function config( $string ){     require 'configuration.php';     $keys = explode('/',$string);     $return = $config;     foreach($keys $key){         $return = $return[$key];     }     return $return; } 

here can too:

config('features/others/foo/bar'); 

if exists:

$config['features'] = array(     'memcached' => true,     'others'  => array( 'foo' => array( 'bar' => 42 ) ) ); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -