It's been a while since I posted here. Few years probably. I'm working on a project, and it would be really helpful if I could figure out a simple way of doing what I am about to describe.
What I am trying to do, is use array values as the access keys to another array, it will be easier for me to show you.
Code: Select all
$keys = array("db", "tables", "messagse");
$config = array(
"db" => array(
"tables" => array(
"messages" => "messages_table",
"users" => "users_table",
),
"settings" => array(
"username" => "db username",
"password" => "db password",
),
),
"lang" => array(
"etc......"
)
);
Temporarily, I've used this:
Code: Select all
$item = $config;
foreach($keys as $k)
{
$item = $item[$k];
}
// $item = "messages_table" (expected result)
Thanks for any help,
Jeff