I checked several similar questions like this, this, and this but remain not clear that, can I get a firm value by operations inside a deep nested array, rather than calling function or assigning a variable?
As an example below to insert at the first position of $arr['row']
depending on $s
:
$s = true; //or false;
$arr = [
'key1'=>'val1',
'key2'=>'val2',
'row'=>[
function($s){
if($s) return array('x'=>'y',...);
else return null;
},
[
'row2a'=>'val2a',
'row2b'=>'val2b',
],
[
'row3a'=>'val3a',
'row3b'=>'val3b',
],
],
];
// Output:
Array(
...
[row] => Array
(
[0] => Closure Object
(
[parameter] => Array
(
[$s] =>
)
)
[1] => Array
(
[row2a] => val2a
[row2b] => val2b
)
...
got Closure Object
not array('x'=>'y',...)
in $arr['row'][0]
. Or it's no way to get value by operations inside an array, but calling function or passing by variables? Thanks.