0

So I may just be completely overcomplicating this for myself but I am trying to get the index of an array in a multidimensional array.

Hopefully showing it makes more sense.

Array
(
    [1234] => Array
        (
            [Name]  => Test
        )
    [5435]  => Array
        (
            [Name]  => Test
        )
)

I have a large array with different numbers as the index and I need to do a foreach through them, but I need that index number. (1234,5435)

Is there any easy way of doing this?

j08691
  • 204,283
  • 31
  • 260
  • 272
Scott
  • 187
  • 2
  • 9
  • what is the criteria to select 1234,5435? –  Jul 19 '13 at 14:18
  • come on. it is in the manual on the most top part! [foreach](http://php.net/manual/de/control-structures.foreach.php) – Michael Walter Jul 19 '13 at 14:20
  • Glad you have found StackOverflow, Scott, and you did write a formal good question. But really, this is something that you could have found with a quick search on google, here, or php.net – cypherabe Jul 19 '13 at 14:24
  • Honestly I knew how to do ($arr as $key=>$val) but I just completely overcomplicated the situation for myself and didn't think it all the way though and feel like an idiot now. – Scott Jul 19 '13 at 14:25

1 Answers1

5

Yes there is.

foreach ($arr as $key=>$val)
{
    //do stuff
}

The $key is the key you need

Jnatalzia
  • 1,687
  • 8
  • 14