# Array get and foreach statement HELP!

**URL:** <https://community.f5.com/t/array-get-and-foreach-statement-help/2633>\
**Category:** Technical Forums\
**Tags:** irules, dev, devops, application-delivery\
**Created:** [February 1, 2011, 2:04pm UTC](https://community.f5.com/t/array-get-and-foreach-statement-help/2633 "2011-02-01T14:04:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![agentile\_2106](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@agentile\_2106](https://community.f5.com/u/agentile_2106)\
**Post date:** [February 1, 2011, 2:04pm UTC](https://community.f5.com/t/array-get-and-foreach-statement-help/2633/1 "2011-02-01T14:04:08Z")

</div>

Hi Guys,

i’m going crazy with a simple array operation in a foreach statement. If i run:

when HTTP\_REQUEST {

array unset colorcount

array set colorcount {

red 1

green 5

blue 4

white 9 }

foreach {color count} [array get colorcount] { log local0. “Color: $color Count: $count”}

i expect a reply “Color: red Count:1”

But on my logs i’ve got:

Feb 1 16:02:51 local/tmm info tmm[23012]: Rule IRULE-SMS-Sender-Rate : Color: blue Count: blue

Feb 1 16:02:51 local/tmm info tmm[23012]: Rule IRULE-SMS-Sender-Rate : Color: 4 Count: 4

Feb 1 16:02:51 local/tmm info tmm[23012]: Rule IRULE-SMS-Sender-Rate : Color: white Count: white

Feb 1 16:02:51 local/tmm info tmm[23012]: Rule IRULE-SMS-Sender-Rate : Color: 9 Count: 9

i’ve done this simple test because i’m wrinting an irule and i’ve recognized that the foreach statement on arrays seems not working!

Please, help

Regards

Tony

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [February 1, 2011, 4:14pm UTC](https://community.f5.com/t/array-get-and-foreach-statement-help/2633/2 "2011-02-01T16:14:18Z")

</div>

Hi Tony,

See the post below for details on this bug:

Unexpected result from foreach loop on 10.2

[http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/afv/topic/aft/1172718/aff/5/showtab/groupforums/Default.aspx](http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/afv/topic/aft/1172718/aff/5/showtab/groupforums/Default.aspx)

Aaron

---

<div class="post-metadata">

**Author:** ![agentile\_2106](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@agentile\_2106](https://community.f5.com/u/agentile_2106)\
**Post date:** [February 2, 2011, 9:17am UTC](https://community.f5.com/t/array-get-and-foreach-statement-help/2633/3 "2011-02-02T09:17:04Z")

</div>

Thanks Aaron,

i’ve found the post yesterday night… Is there any workaround as far as you know?

it is a foreach statement issue or an array issue?

i have to implement an irule very similar to this one

> **[DevCentral - An F5 Technical Community](https://community.f5.com/)**
>
> DevCentral is an online technical community where engineers and practitioners collaborate, share knowledge, and solve problems related to F5 technologies and industry trends.

i was thinking about “table commands” instead of the use of arrays.

what do you think?

Thanks for your help!

Regards

Antonio
