Home  >  Article  >  Backend Development  >  How to remove the first two items of an array in php

How to remove the first two items of an array in php

青灯夜游
青灯夜游Original
2022-02-25 19:27:022251browse

php method to remove the first two items of the array: 1. Use the array_splice() function to intercept all elements of the array starting from subscript 2. The syntax is "array_splice($arr,2)"; 2. Use array_slice() function, syntax "array_slice($arr,2)".

How to remove the first two items of an array in php

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

php before removing the array Two items

Method 1: Use the array_splice() function

When the array_splice() function deletes some elements of the array, these will be The deleted elements are formed into a new array, and the new array is returned; therefore the array_splice() function can be used to intercept array fragments.

How to remove the first two items of an array in php

Method 2: Use array_slice() function

array_slice() function is one provided by PHP to intercept arrays Function that extracts a fragment from an array.

How to remove the first two items of an array in php

Recommended learning: "PHP Video Tutorial", "PHP ARRAY"

The above is the detailed content of How to remove the first two items of an array in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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