In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to delete the first five elements with the php array". The explanation in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "how to delete the first five elements with the php array".
In php, you can use the array_splice () function to delete the first five elements of an array by setting the second parameter of the function to 0 and the third parameter to 5, with the syntax "array_splice ($arr,0,5);".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
To delete the first five elements in the php array, you can use the array_splice () function.
The array_splice () function is a powerful function with multiple functions: you can insert array elements, you can replace array elements, and of course you can delete array elements (after all, the job of the array_splice () function is to delete the specified element and replace it with other values).
The syntax of array_splice () is as follows:
Array array_splice (array & $arr, int $start [, int $length = 0 [, mixed $replacement]])
Parameter description:
Arr represents an array.
Start indicates where to start the deletion (subscript):
If start is positive, it is deleted from after going.
If the start is negative, it is deleted from back to front, starting from the end of the arr-start. For example,-2 means starting with the penultimate element of the array.
Length is an optional parameter that indicates the number of elements deleted:
If length is positive, it means deleting length elements
If length is negative, all elements from start to the reciprocal length at the end of the array will be deleted
If omitted, all elements from start to the end of the array are deleted.
Replacement is an optional parameter that represents the value to replace. If replacement has more than one value, it needs to be set to an array, and if there is only one value, it can not be set to an array.
To use the array_splice () function to delete the first five elements of the array, simply set the second parameter of the function to 0 and the third parameter to 5.
Implementation code:
Output result:
As you can see, the first five elements in the array have been deleted!
Thank you for your reading, the above is the content of "how to delete the first five elements with the php array". After the study of this article, I believe you have a deeper understanding of the problem of how to delete the first five elements with the php array. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.