How to get the value of php Array
This article mainly introduces how to obtain the value of php array, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
The method to get the value: 1, use the "array_shift ($arr)" statement; 2, use the "array_pop ($arr)" statement; 3, use the "array_splice ($arr, number of elements)" statement; 4, use the "array_slice ($arr, number of elements)" statement.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The method of getting the value of php array
Method 1: use the array_shift () function to get the value of the first element in the array
Output result:
Method 2: use the array_pop () function to get the value of the last element in the array
Let's start with an example:
Output result:
Method 3: using the array_rand () function to randomly obtain multiple element values
Output result:
Method 4: use the array_splice () function to obtain multiple element values
The output is as follows:
Method 5: use the array_slice () function to get multiple elements
The output is as follows:
Thank you for reading this article carefully. I hope the article "how to get the value of php Array" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!