Problem: by default, PHP array_merge works like this ... it will overwrite a non-blank value with a blank value.
$foobar = Array('firstname'=>'peter','age'=>'32','nation'=>'');
$feebar = Array('firstname' => '','lastname' => 'griffin', age =>'33','nation'=>'usa');
print_r(array_merge($foobar,$feebar));
/*
Array
(
[firstname] => // <-- feebar set this to blank, NOT COOL!
[age] => 33 // <-- feebar set this to 33, thats cool
[lastname] => griffin // <-- feebar added this key-value pair, thats cool
[nation] => usa // <-- feebar filled in a blank, thats cool.
)
*/
Question: What's the fewest-lines-of-code way to do array_merge where blank values never overwrite already-existing values?
print_r(array_coolmerge($foobar,$feebar));
/*
Array
(
[firstname] => peter // <-- don't blank out a value if one already exists!
[age] => 33
[lastname] => griffin
[nation] => usa
)
*/
UPDATE: I modified the original question example to clarify things a bit.