Home > Backend Development > PHP Tutorial > php-offset(距离末端这么远的地方开始)

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

WBOY
Release: 2016-06-02 11:35:00
Original
1382 people have browsed it

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’么??

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template