Return PHP array name

You can use a foreach statement to get the key value pair of the array:

$outer_arr = array('kanye' => array('Kanya', 'Janaye', 'Kayne', 'Kane'));
foreach($outer_arr as $key => $val) {
    print($key); // "kanye"
    print_r($val); // Array ( [0] => Kanya [1] => Janaye [2] => Kayne [3] => Kane )
}

If you just need to get the keys, you can use array_keys

$myArray = array(
    "Kanye" => array("Kane", ...)
    "West" => array("Wst", ...)
);

print_r(array_keys($myArray));
/*
array (
    0 => Kanye
    1 => West
)
*/

Tags:

Php

Arrays