I hope this is no stupid question, but I have no idea how to deal with this: There is a given associative array and I must get its values with one function. The function should look like:
function getValFromArray([$key1, $key2, $key3, ...]);
The given Array is flexible and looks like (example):
$arr = [
'foo' => [
'bar' => [
'baz' => [
'qux' => [
'quux' => 7
]
]
]
],
'foo2' => [
'bar2' => 1
]
];
Calling the function should now return:
echo getValFromArray(['foo', 'bar', 'baz', 'qux', 'quux']); // -> 7
And with other parameters:
echo getValFromArray(['foo2', 'bar2']); // -> 1
Is there a fast solution to get these values from the array, maybe with own PHP build in functions?