Ilya Beloborodov2017-06-16 10:31:09
Ilya Beloborodov, 2017-06-16 10:31:09

Anonymous function as array element in php?

Here is the array

$arr = [
     'url' => 'news.html',
     'data' => function () {
            return 123123123;

if you call $arr['data']it, it will print out
object(Closure)#138 (0) { }
what to do, what would return what you need?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Anton, 2017-06-16

The function needs to be called.
Try like this$arr['data']();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question