我有一个这样的数组。我想要的是获取特定值的索引值。即,我想知道值“UD”等的索引。
Array
(
[0] => LN
[1] => TYP
[2] => UD
[3] => LAG
[4] => LO
)
我该怎么做?
最佳答案
array_search函数是为这种用法而设计的
片段:
$index = array_search('UD', $yourarray);
if($index === false){ die('didn\'t found this value!'); }
var_dump($index);
关于php - 查找对应数组值的键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1678851/