Conditionally add associative element to array

$a = array('a' => 'abc') + ($condition ? array('b' => 'xyz') : array());

Leave a Comment