I have an array with 2 kinds of keys, strings and integers. I want to do foreach() on this array and want to do it for numeric keys only. What is the most elegant way of doing it?
I have an array with 2 kinds of keys, strings and integers. I want
Share
Here’s a complicated method using
array_filter()to return the numeric keys then iterate over them.It’s much easier though to just foreach over everything:
Edit Misread original post and thought I saw “numeric” rather than “integer” keys. Updated to use
is_int()rather thanis_numeric().