In PHP closures are quite useful. But can I use closures to set array elements?
$configs = [
"y" => "1",
"x" => function() { return "xxx"; },
];
echo $configs["y"];
echo $configs["x"]; // error
gives
Recoverable fatal error: Object of class Closure could not
be converted to string on line 6 (last line)
Is there a chance to cast the closure or anything the like that the closure works for array initialization?
Working with PHP 7.1.4 on MacOSX