当前位置:Gxlcms > PHP教程 > php-offset(距离末端这么远的地方开始)

php-offset(距离末端这么远的地方开始)

时间:2021-07-01 10:21:17 帮助过:2人阅读

php

array array_slice ( array $array , int $offset [, int $length [, bool $preserve_keys ]] )
array_slice() 返回根据 offset 和 length 参数所指定的 array 数组中的一段序列。

如果 offset 非负,则序列将从 array 中的此偏移量开始。如果 offset 为负,则序列将从 array 中距离末端这么远的地方开始(这是什么意思)。
$input = array("a", "b", "c", "d", "e");
$output = array_slice($input, -1); // returns "e"

如果是距离末端‘e’开始左移一位的话,那不应是‘d’么??

人气教程排行