Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一系列类似于以下内容的缩略图:
$thumbnails = array(1,2,3,4,5,6,7,8,9,10);
首先,我想根据当前应用 6 的限制,key = 3因此数组应该返回:3,4,5,6,7,8。
key = 3
3,4,5,6,7,8
如果我按下下一个链接,数组应该返回4,5,6,7,8,9:
4,5,6,7,8,9
如果我按上一个链接,数组应该返回:2,3,4,5,6,7.
2,3,4,5,6,7
使用array_slice():
array_slice()
$start = 3; $limit = 6; $limited = array_slice( $thumbnails, $start - 1, $limit);