- Joined
- Nov 16, 2009
- Messages
- 866
- Reaction score
- 580
Hello
I need some help on how todo something in php. The best explaination I have on my problem is "get multifimensional array field from an array".
I will let the code speak for itself.
My example array:
What I would like todo:
etc...
Any effective solution on this?
I need some help on how todo something in php. The best explaination I have on my problem is "get multifimensional array field from an array".
I will let the code speak for itself.
My example array:
Code:
Array
(
[database_credentials] => Array
(
[host] => localhost
[username] => root
[password] => root
[database] => ragezone
[port] => 3306
)
[cache_prefix] => cache_
[database_table_prefix] => database_
[ragezone] => Array
(
[members] => Array
(
[0] => oleaa
[1] => oleaa2
[2] => oleaa3
)
[threads] => Array
(
[one] => Learn PHP in 5 years
[two] => Learn Java in 6 years
[three] => Learn
)
[post] => I have no posts
)
)
What I would like todo:
Code:
GetConfig('database_credentials');
Would return:
Array
(
[host] => localhost
[username] => root
[password] => root
[database] => ragezone
[port] => 3306
)
Code:
GetConfig(['database_credentials', 'host']);
Would return:
string(9) "localhost"
Code:
GetConfig(['ragezone', 'members', 0]);
Would return:
string(5) "oleaa"
Code:
GetConfig(['ragezone', 'threads', 'one']);
Would return:
string(20) "Learn PHP in 5 years"
Code:
GetConfig('cache_prefix');
Would return:
string(6) "cache_"
Any effective solution on this?