In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "php how to delete the nth element of the array", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "php how to delete the nth element of the array" article.
In php, you can use array_splice () to delete the nth element of the array, and this function can delete a specified number of elements from a specified location (subscript), simply by setting the second parameter to (nmur1) and the second parameter to 1; the syntax is "array_splice ($arr,n-1,1)".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use the array_splice () function to delete the nth element of the array.
The array_splice () function deletes a specified number of elements from a specified location (subscript).
To delete the nth element using the array_splice () function, just set the second parameter to (NMUI 1) and the second parameter to 1.
Example 1: delete the second element
Example 2: delete the sixth element
Description: array_splice ()
Array_splice () is a powerful array function that can delete, add, and replace elements according to different parameter settings.
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.
If the result of the combination of start and length is that no elements are deleted, then the value contained in replacement will be inserted at the location specified by start.
Note that replacing array elements with replacement does not retain the original key name.
Return value: returns an array of deleted elements.
The above is about the content of this article on "how to delete the nth element of an array by php". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please follow the industry information channel.
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.