How php queries array values based on array location
This article will explain in detail how php queries array values according to the location of the array. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Php query the array value according to the array location: 1, use the "$array variable name [subscript value]" statement; 2, use the "array_slice ($arr, subscript value, 1)" statement; 3, use the "array_splice ($arr, subscript value, 1)" statement.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The method of querying array values according to array position by php
Method 1: use the form of $array variable name [subscript value]
Method 2: using the array_slice () function
The array_slice () function can intercept a value of a specified length based on the given array position and return the truncated subarray.
If you just want to get an element, you can set the third parameter of the array_slice () function to 1.
Example: get the element value with subscript 1
Method 3: using the array_splice () function
Similar to the array_slice () function, if you just want to get an element, you can set the third parameter of the array_splice () function to 1.
This is the end of the article on "how php queries array values according to array location". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.