Combine multiple arrays with array merge

Hi everyone,

I am looking for a way to merge multiple arrays into one.

I can use the array merge operation to combine one set of arrays, like this below:
Mapper: Array Merge / Array Push - iPaaS Transformers / Mappers - Alumio

But how would I achieve this is there is not a predefine amount of arrays?
I will be using the merged storage subscriber and I will end up with 3 or more storage objects that will be added to that.

How can I merge all arrays into one array without knowing how many arrays I got?

PHP Example:

$data = [
   0 => [ "data", "more data"],
   1 => [ "data", "more data"],
   2 => [ "data", "more data"],
   // ETC
]

$merged_array = [];
foreach($data as $array){
  array_merge($merged_array, $array);
}
1 Like

Hi @Rickvzanden
Is this the example you are looking for?

2 Likes

I found a way, but its still a bit wonky I believe:

This combines the data I needed and flattens them into a single array:

For example, my data in the the tester containers two arrays with each two records:
image

This results into a flattened array where the first key is the array key.
So we remove this one and we are left the pairs containing the data.
image

But I think there are maybe better ways to do this? It feels so redundant flattening the array and removing the first key.

Ah yes, the list get values was the missing piece, that is what I searched for.

Thanks @catalin !

Hi Rick.

I also found a fix using JMESPath, it is very simple.
Now you can choose between 2 solutions :wink:

3 Likes

@mko
Thank you for giving another way to solve this!

1 Like