Extract values of an array by key name

I’m trying to extract particular values from an array based on the key. This would be fine if they all shared the same key name and/or I knew exactly how many there would be of them. But I don’t.

Please see attached screenshot of the array I’m trying to work with.

I want to only work with the key values of Photos0, Photos1, Photos2 etc (which could go up to 25). How do I write a formula that minifies the array to only those items?

Appreciate your help.

Hi @Ally_Colquhoun,

Welcome to this community. :slight_smile:
In order to create a new array with only the key as values, you can use the map() function.

For example:

{{map(2.array; "key")}}

(Change the array to your array variable.)

1 Like

Hey! Thanks so much for getting back to me!

The problem is that the key is not always the same. A number is always appended to the key from 0 upwards (depending on how many items there are). So It goes photos0, photos1, photos2 etc…

So my question is how do I target the key (photos) but ignore those annoying numbers on the end?

I was thinking it can be done with one of the other functions available, or even a regex perhaps?

Many thanks

Hi @Ally_Colquhoun ,

In this case, you could use a combination of an array iterator and array aggregator. Where you then apply a filter in between.
I created a small demo…

Glenn - Callinetic


Hi Glenn

That’s the secret sauce I was looking for, thank you so much for taking the time!!


1 Like