How to get the first few data from php array

L
Release: 2023-03-01 10:50:01
Original
5760 people have browsed it

How to get the first few data from php array

array_slice() function removes a segment of value from 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 tutorial: "PHP Tutorial"

The above is the detailed content of How to get the first few data from 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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!