的最後3個元素我有一個數組:PHP獲取數組
[13] => Array
(
[0] => joe
[1] => 0
[14] => Array
(
[0] => bob
[1] => 0
)
[15] => Array
(
[0] => sue
[1] => 0
)
[16] => Array
(
[0] => john
[1] => 0
)
[17] => Array
(
[0] => harry
[1] => 0
)
[18] => Array
(
[0] => larry
[1] => 0
)
我怎樣才能獲得最後3個元素,同時保留了鑰匙? (數組中的元素的數量可能會有所不同,所以我不能在第二個元素後只需快訊)
所以輸出將是:
[16] => Array
(
[0] => john
[1] => 0
)
[17] => Array
(
[0] => harry
[1] => 0
)
[18] => Array
(
[0] => larry
[1] => 0
)
謝謝!不知道array_slice()有第四個參數。 – alex 2011-03-29 06:59:36