How php checks the line in which the value is in the array
This article mainly introduces the relevant knowledge of "how to check the value of php in the array". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article "how to check the value of php in the array" can help you solve the problem.
Check the number of rows: 1, use the "array_values ($arr)" statement to convert the specified array into an indexed array; 2, use the "array_search (" value ", indexed array)" statement to search the specified value in the indexed array and return the corresponding index; 3, use the "index value + 1" statement to calculate the number of rows of the specified value in the array.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The line in which the php check value is in the array
Implementation method:
Use array_values () to get the values of all the elements in the array and return an array containing all the key values, which turns the array into an indexed array.
Use array_search () to search for the given value in the indexed array and return the corresponding index value
The array index value starts at 0, so the number of rows of the specified value needs to be added by 1 to the index value obtained.
Implementation example: