PHP obtains the position of an element in the array and the array_keys function application. As we all know, PHP itself has many built-in functions, which is also an important reason for using PHP to greatly improve development efficiency. There are many methods to obtain the position of an element in an array, among which PHP itself is well known, PHP has many built-in functions. this is also an important reason why PHP can greatly improve development efficiency. There are many methods to obtain the element location in the array, among them, PHP itself has a built-in function array_keys (). the following code can print all the built-in functions of PHP:
The code is as follows:
Print_r (get_defined_functions ());
?>
The syntax of array_keys is as follows:
The code is as follows:
Array_keys (array, value, [strict])
When strict is set to true, the strict matching mode of data type verification is triggered. the default value is false. the following code shows a simple application of array_keys.
The code is as follows:
$ Test = array (10, 20, 30, "10", "20", "30 ");
Print_r (array_keys ($ test, "10", true); // exact match
// Output:
// Array ([0] => 3)
?>
...