// ou considerando sua estrutura de array:
$array = array(
'string1' => array('a' => '', 'b' => '', 'c' => ''),
'string2' => array('a' => '', 'b' => '', 'c' => ''),
'string3' => array('a' => '', 'b' => '', 'c' => ''),
);
// você poderia apenas
function findIndexOfKey($key_to_index,$array){
return array_search($key_to_index,array_keys($array));
}
// executado
print "\r\n//-- Method 1 --//\r\n";
print '#index of: string1 = '.findIndexofKey('string1',$array)."\r\n";
print '#index of: string2 = '.findIndexofKey('string2',$array)."\r\n";
print '#index of: string3 = '.findIndexofKey('string3',$array)."\r\n";
// alternativamente
print "\r\n//-- Method 2 --//\r\n";
print '#index of: string1 = '.array_search('string1',array_keys($array))."\r\n";
print '#index of: string2 = '.array_search('string2',array_keys($array))."\r\n";
print '#index of: string3 = '.array_search('string3',array_keys($array))."\r\n";
// recursivamente
print "\r\n//-- Method 3 --//\r\n";
foreach(array_keys($array) as $key => $value){
print '#index of: '.$value.' = '.$key."\r\n";
}
// saídas