Home > php教程 > PHP开发 > Use of php array_slice function and detailed explanation of parameters

Use of php array_slice function and detailed explanation of parameters

高洛峰
Release: 2017-03-18 16:10:24
Original
1614 people have browsed it

<?php 
/* 
用手册上的例子 
*/ 
$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" 
?>
Copy after login

The key point is that length is negative. It means taking the array until it is as far away as length from the end of the array

For more related articles about the use of the php array_slice function and detailed explanation of parameters, please pay attention to the PHP Chinese website!

Related articles:

php array function sequence array_slice()

php array_slice takes out a sequence instance in the array

Analysis of array_slice and array_splice functions in php

Related labels:
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