In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how php removes array keys". In daily operation, I believe many people have doubts about how php removes array keys. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how php removes array keys". Next, please follow the editor to study!
Php to remove the array key value method: 1, use the "array_keys ($array)" statement, you can remove all the key values, return all the key names of the array; 2, use the "array_splice ($array,$start,$length)" statement, you can remove the specified location of one or more key values.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
There are many ways to remove array keys from php. Here are two ways:
Method 1: use the array_keys () function
The array_key () function can get some or all the key names in the array.
The array_key () function removes all the keys from the array and returns a new array containing all the key names.
Use syntax:
Array_keys ($array)
Example:
Method 2: use the array_splice () function
The array_slice () function is used to intercept an array, that is, to extract a fragment from the array.
Use syntax:
Array_splice ($array,$start,$length)
Parameters:
Array represents the array to be intercepted.
Start indicates where to start the intercept (subscript):
If start is positive, it is intercepted from the back of the go.
If the start is negative, it is intercepted from back to front, starting at the distance 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 intercept length:
If length is positive, it indicates the number of elements intercepted
If length is negative, the intercepted fragment will terminate at the position of length at the end of the distance array
If omitted, it starts at the start position and goes all the way to the end of the array.
Use the array_splice () function to remove one or more key values from a specified location.
Example 1:
Example 2:
At this point, the study of "how to remove array keys from php" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.