I have a great couple of variables named $value1
, $value2
etc. I want to create an array key for each variable only if the variable is not empty. Something like this:
$array = array(
If (!empty($value1)) { "bar" => "foo", }
If (!empty($value2)) { "foo" => "bar", }
);
How do I do this and what would be good practice?