PHP - Inside 2d Array Function
I have a 2d array that includes an anonymous function that I would like to execute. For some reason, I am drawing a space on how to call the function.
The following fails:
$someArray[] = ['somevalue', function () {echo "test function";}];
$someArray[0][1]();
Mistake:
Notice: Undefined variable
Fatal error: Function name must be a string
If I do the following it works
$someFunc = $someArray[0][1];
$someFunc();
+3
source to share