Put an array_merge function call outside of foreach statement