The problem is that $arr is a variable defined outside the function, so it is impossible to access from it.
Try just importing the $arr variable into the closure with use ($arr) , but that will not work, because $arr is not really defined at the time you define your function.
While $arr truly a global variable, you can update such a function to make it work:
'index2' => function() { global $arr; $arr['index1'](); // foo echo 'bar'; //bar }
A better idea is to pass an array as a parameter to a function, for example:
'index2' => function($a) { $a['index1'](); // foo echo 'bar'; //bar }
... and name it as follows:
$arr['index2']($arr);
source share