Sorry for repeated (no doubt) question, but other answers have slightly confused me.
So I have an array like this:
$testflag = '';
$test = array(
'auxiliaryFields' => array(
array(
'key' => 'extra1',
'label' => 'TEST',
'value' => 'TEST',
'textAlignment' => 'PKTextAlignmentLeft'
)
if ($testflag != ''){
,
array(
'key' => 'extra2',
'label' => 'TEST2',
'value' => 'TEST2',
'textAlignment' => 'PKTextAlignmentLeft'
)
}
));
var_dump($test);
Now, I've read that you can't use code inside an array, so my question is how to do the above? In this example it's just 2 arrays (extra1 & extra2) but I have 4 arrays in total in my actual code. The condition is basically if session:form:element:not_null then include extra2 - 3 - 4 and so on, if it IS null, do nothing.
Can someone please help?
arrayexpression (and this is a duplicate).?:usage will result in a value, but cannot specify "an absence of a value".