2010-03-10 106 views
1

我怎麼能發現twoVal在位置1?陣列中的位置

$arr = array('Cool Viski' => array('oneVal' => '169304', 
            'twoVal' => '166678', 
            'threeVal' => '45134')); 

回答

8
$position = array_search('twoVal', array_keys($arr['Cool Viski'])); 
1

嘗試array_keys希望它會幫助你

$searchValue = "twoVal"; 
$keys = array_keys($array, $searchValue);