Array function library: Array_slice

Source: Internet
Author: User
Keywords array_slice php Chinese function manual array function library
Tags aliyun array array function library array_slice function function library html http

Array_slice

(PHP4)

Array_slice---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Extract part of an array

Syntax: array array_slice (array array, int offset, int [length]);

Description:

This function returns a part of the element from the array, and if offset is a positive number, the retrieved part starts at the offset in the array, and the offset is negative, starting at the end of the array. If length is given and is positive, the length of the element will be retrieved, and if length is negative, the length of the element at the end of the array will be stopped, and if this argument is omitted, the returned portion will be from offset to the end of the array.

Example:

<?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"
?>

Reference: Array_splice ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.