Home > php教程 > php手册 > php array_slice函数的使用以及参数详解

php array_slice函数的使用以及参数详解

WBOY
Release: 2016-06-13 12:26:49
Original
990 people have browsed it

复制代码 代码如下:


/*
用手册上的例子
*/
$input = array ("a", "b", "c", "d", "e");
$output = array_slice ($input, 2); // returns "c", "d", and "e",
$output = array_slice ($input, 2, -1); // returns "c", "d"
$output = array_slice ($input, -2, 1); // returns "d"
$output = array_slice ($input, 0, 3); // returns "a", "b", and "c"
?>


重点说下length 为负.它表示取数组一直到距离数组末端length这么远的距离

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template