0

I can't understand how to get numeric index of "Index1" in such a structure:

$arr = array('Index','Index1' => array("one","two","three"),'Index2');

i'm trying to use array_search like so:

$index = array_search("Index1",$arr);

but it doesn't work; Thanks

1 Answers1

0

As mentioned, there is no numeric index for that element, as its key is a string.

However if you just want to find its position in the array:

$position = array_search("Index1",array_keys($arr),true);
Steve
  • 20,703
  • 5
  • 41
  • 67