您如何建议获取数组中最后一个匹配值的键?
$arr = array(
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 5,
7 => 5,
8 => 5,
9 => 5, // <--- this is the key I'm after!
10 => 6,
11 => 7,
12 => 8,
13 => 9,
14 => 10,
15 => 11);
function returnLastMatching($haystack,$needle) {
// return 9
}
echo returnLastMatching($arr,5); // "9"