Anonymous function in array

后端 未结 1 631
北荒
北荒 2021-01-20 05:19

I have declared

$func = array(
    \'a\' => array(
        \'b\' => function() {
            echo \"hello\";
        }
    )
);

I try

1条回答
  •  不知归路
    2021-01-20 05:23

    What you did works. Try this:

     array(
            'b' => function() {
                echo "hello";
            }
        )
    );
    $call = $func['a']['b'];
    $call();
    

    See also here.

    0 讨论(0)
提交回复
热议问题