If I have an array called myFunctions, it contains php function names like this ...
$myFunctions= array("functionA", "functionB", "functionC", "functionD",....."functionZ");
How can I call all these functions with this array?
You can use function variables
PHP supports the concept of variable functions. This means that if parentheses are added to the variable name, PHP will look for a function with the same name as the variable that will be evaluated and try to execute it. Among other things, this can be used to implement callbacks, function tables, etc.
foreach($myFunctions as $func) { $func(); }
Another way: call_user_func
foreach($myFunctions as $myFunction) { call_user_func($myFunction); }
or
array_walk($myFunctions,'call_user_func');
Source: https://habr.com/ru/post/1201458/More articles:Is there a way to do functional testing using googleMaps (android)? - androidWhy am I losing transparency when calling BitBlt or CopyRect? - delphiHow to rename ForeignKey input field in Django Rest Framework - pythonHow to draw part of the image? - delphiDynamic timezone offset in elasticsearch aggregation? - timezonePuzzle: A JS function that returns itself until there are no arguments - javascriptHow to slow down animation using Facebook Pop? - iosIs it possible to write / wrap exception handling components (try, catch) in different classes? - c ++Installing nltk for Python 3.4 on Mac OS 10.9 - pythonAltBeacon onBeaconServiceConnect not called - androidAll Articles