How to intercept the first few of php array

藏色散人
Release: 2023-03-08 19:44:02
Original
5081 people have browsed it

How to intercept the first few data of php array: first create a PHP sample file; then define an array; finally intercept the first few data of the array through "array_slice($arr,0,4);" .

How to intercept the first few of php array

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php function array_slice is used ( Get the first and last digits of the array)

array_slice() function takes out a segment of value in the array based on conditions and returns it.

Syntax: array_slice(array,start,length,preserve)

Get the first 4 digits of the array

array_slice($arr,0,4);
Copy after login

Get the last 4 digits of the array

array_slice($arr,-4,4);
Copy after login

or

array_slice($arr,-4);
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to intercept the first few of php array. For more information, please follow other related articles on the PHP Chinese website!

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