Can you have an “if” statement within an “array” function?
$my_array = array(
'foo' => $foo,
'bar' => 'bar',
'lorem' => $lorem,
if($z == 'z'){ 'ipsum' => $ipsum }
);
my question of course pertains to line 5, the 4th item in the array. It doesn’t seem to want to work, is there a bettwe way to do it?
You can’t do that. Just add the
ifstatement after.