$arr = array(
'key1' => 1,
'key2' => 'value2',
'key3' => function() {
if (someConditionSomewhere) {
return 3;
} else {
return 'value3';
}
},
);
Let's look at example above. This is what I would love to get in PHP. Create an array, type determinant values there by myself and then for the dynamic value pass a function. I know you can pass anonymous function to arrays since 5.3. But I am not interested in the function alone but rather what it returns. So if I do this later: $arr[key3] I want to get either 3 or 'value3' depending what is there. NOT the function itself.
Is it even possible in PHP?