As we all know, PHP 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 location of elements in an array, among them, PHP itself has a built-in function array_keys (). The following code can print all the built-in functions of PHP:
Copy codeThe Code is as follows:
<? Php
Print_r (get_defined_functions ());
?>
The syntax of array_keys is as follows:
Copy codeThe 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.
Copy codeThe Code is as follows:
<? Php
$ Test = array (10, 20, 30, "10", "20", "30 ");
Print_r (array_keys ($ test, "10", true); // exact match
// Output:
// Array ([0] => 3)
?>