Is it possible to iterate over an associative array with wildcard "*" using foreach loop?
Asked
Active
Viewed 1,902 times
1 Answers
3
No. IEEE 1800-2012 § 7.8.1 Wildcard index type states:
Associative arrays that specify a wildcard index type shall not be used in a foreach loop (see 12.7.3) or with an array manipulation method (see 7.12) that returns an index value or array of values.

Greg
- 18,111
- 5
- 46
- 68

Matthew Taylor
- 13,365
- 3
- 17
- 44
-
3The reason for this restriction is that the `foreach` construct needs to declare a local iterator variable, and that variable needs a type. The wildcard index is left over from the Vera language, which did not have the ability to declare an index type. Do not use wildcard indexes. – dave_59 Feb 28 '17 at 17:14