I will give you quick run down of what I am doing.
I am using wordpress with the advanced custom fields plugin. This is a php based question because these get_fiel
array_merge
only accepts arrays as parameters. If one of your parameters is null, it will raise an error :
Warning: array_merge(): Argument #x is not an array...
This error won't be raised if one of the arrays is empty. An empty array is still an array.
Two options :
1/ Force the type to be array
$downloads = array_merge( (array)$gallery_location, (array)$gallery_studio );
2/ Check if variables are arrays
$downloads = array();
if(is_array($gallery_location))
$downloads = array_merge($downloads, $gallery_location);
if(is_array($gallery_studio ))
$downloads = array_merge($downloads, $gallery_studio);
PHP Sandbox
You can use the following way for merger your arrays:
$c = (array)$a + (array)$b