How does php find a value in an array
In this article Xiaobian for you to introduce in detail "php how to find a value in the array", the content is detailed, the steps are clear, the details are handled properly, I hope this "php how to find a value in the array" article can help you solve your doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.
Search method: 1, use "in_array ($search,$arr,$type)" statement; 2, use "array_search ($search,$arr,$type)" statement; 3, use "array_key_exists ($search,$arr)" statement.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The method of finding a value in an array by php
Method 1: use the in_array () function
The in_array () function searches for the existence of the specified value in the array.
Method 2:array_search () function
The array_search () function, like in_array (), looks for a key value in the array. If the value is found, the key name of the matching element is returned. If it is not found, false is returned.
Method 3: use the array_key_exists () function
The array_key_exists () function checks whether the specified key name exists in an array, returns true if the key name exists, and false if the key name does not exist.
Read here, this article "php how to find a value in the array" article has been introduced, want to master the knowledge of this article still need everyone to practice and use to understand, if you want to know more related articles, welcome to follow the industry information channel.