獲取下一個數組項我有一個數組使用鑰匙PHP
Array(1=>'test',9=>'test2',16=>'test3'... and so on);
我如何通過傳遞鍵獲得下一個數組項。
例如,如果我有密鑰9
那麼我應該得到test3
作爲結果。如果我有1
那麼它應該返回'test2'
作爲結果。
編輯,以使其更清晰
echo somefunction($array,9); //result should be 'test3'
function somefunction($array,$key)
{
return $array[$dont know what to use];
}
我覺得這是一個重複。檢查這個問題 - > http://stackoverflow.com/questions/6141717/next-element-in-a-associative-php-array – Nobita