I saw people doing this:
usort($array, function() { //... });
How to write a similar implementation using my own function? For instance,
runIt(function() { //... });
and implementation runIt:
runIt
function runIt() { // do something with passed function }
function() {}is called an anonymous function and can be called using the parameter name. For instance,
function() {}
function runIt($param) { $param(); } runIt(function() { echo "Hello world!"; });
If you are interested in var-args, then:
function runIt() { foreach(func_get_args() as $param) { $param(); } } runIt(function() { echo "hello world"; });
Source: https://habr.com/ru/post/1695268/More articles:Подключение двух таблиц, чтобы результаты отображались в нескольких столбцах - sqlExtracting a number from a string after a specific character - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1695265/improve-the-speed-of-mapping-a-list-of-lab-colors-to-a-second-list-of-lab-colors&usg=ALkJrhjySbHkNJauJJNFU9SKwV4DM7uLQQHow to get the value of an option that starts with the "+" symbol? - cHow can I get around the rewrite address to not redirect the control flow? - cPython date and time countdown list in plural - pythonHolo Lens Development in Unity and Windows 7 - windows-7https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1695271/stop-sending-the-access-token-with-the-response-body-in-yii2&usg=ALkJrhiqXbtAKJtd4MUBYPz1XA7e2vKXMwПрограммно получить список всех включенных пакетов Perl - perlback reference to temporary when dereferencing cards are named - c ++All Articles