# Extract values of an array by key name

**URL:** https://community.make.com/t/extract-values-of-an-array-by-key-name/6513
**Category:** Questions
**Tags:** regular-expressions, arrays, functions
**Created:** [January 10, 2023, 3:52am UTC](https://community.make.com/t/extract-values-of-an-array-by-key-name/6513 "2023-01-10T03:52:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ally\_Colquhoun](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ally\_Colquhoun](https://community.make.com/u/Ally_Colquhoun)
#### Post date: [January 10, 2023, 3:52am UTC](https://community.make.com/t/extract-values-of-an-array-by-key-name/6513/1 "2023-01-10T03:52:45Z")

</div>

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.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/8/83b53e6756a4962a62439448adb093234ecb024b.png)

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.

---

<div class="post-metadata">

### Author: ![Callinetic](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/callinetic/32/93482_2.png) [@Callinetic](https://community.make.com/u/Callinetic)
#### Post date: [January 10, 2023, 7:07am UTC](https://community.make.com/t/extract-values-of-an-array-by-key-name/6513/2 "2023-01-10T07:07:09Z")

</div>

Hi @Ally_Colquhoun,

Welcome to this community. 🙂  
In order to create a new array with only the key as values, you can use the `map()` function.  
[https://www.make.com/en/help/functions/array-functions#map-complex-array--key--key-for-filtering---possible-values-for-filtering-separated-by-a-comma--](https://www.make.com/en/help/functions/array-functions#map-complex-array--key--key-for-filtering---possible-values-for-filtering-separated-by-a-comma--)

For example:

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

```

(Change the array to your array variable.)

---

<div class="post-metadata">

### Author: ![Ally\_Colquhoun](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ally\_Colquhoun](https://community.make.com/u/Ally_Colquhoun)
#### Post date: [January 10, 2023, 7:41am UTC](https://community.make.com/t/extract-values-of-an-array-by-key-name/6513/3 "2023-01-10T07:41:14Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Callinetic](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/callinetic/32/93482_2.png) [@Callinetic](https://community.make.com/u/Callinetic)
#### Post date: [January 10, 2023, 10:31am UTC](https://community.make.com/t/extract-values-of-an-array-by-key-name/6513/4 "2023-01-10T10:31:51Z")

</div>

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…

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/7/74e76db42879012592dddbae183b372c45c97d8d.png)  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/7/737a97a8cbb6307d0d53cac5130407790e9f9722.png)  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/c/cea87e5269229d46e471b830ed4543b91e68a7ee.png)

Glenn - [Callinetic](https://www.callinetic.be/)

---

<div class="post-metadata">

### Author: ![Ally\_Colquhoun](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ally\_Colquhoun](https://community.make.com/u/Ally_Colquhoun)
#### Post date: [January 10, 2023, 8:10pm UTC](https://community.make.com/t/extract-values-of-an-array-by-key-name/6513/5 "2023-01-10T20:10:52Z")

</div>

Hi Glenn

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

Ally

---

<div class="post-metadata">

### Author: ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)
#### Post date: [September 7, 2023, 3:20pm UTC](https://community.make.com/t/extract-values-of-an-array-by-key-name/6513/6 "2023-09-07T15:20:46Z")

</div>


