For merging values of a multidimensional array into one array