Ben gibi bir dizi var ki:
Array
(
[0] => Array
(
[Data] => Array
(
[id] => 1
[title] => Manager
[name] => John Smith
)
)
[1] => Array
(
[Data] => Array
(
[id] => 1
[title] => Clerk
[name] =>
(
[first] => Jane
[last] => Smith
)
)
)
)
Ben dizi dizin yolu olarak hareket ve eval kullanmadan uygun dizisi değerini döndürür () olacak ben bir dize iletebilirsiniz bir işlev oluşturmak mümkün olmak istiyorum. Bu mümkün mü?
function($indexPath, $arrayToAccess)
{
//$indexPath would be something like [0]['Data']['name'] which would return
//"Manager" or it could be [1]['Data']['name']['first'] which would return
//"Jane" but the amount of array indexs that will be in the index path can
//change, so there might be 3 like the first example, or 4 like the second.
return $arrayToAccess[$indexPath] <-obviously wont work
}