There are many methods to obtain the position of an element 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, if you are interested, you can learn how to use the array_keys () function at the same time. as we all know, PHP has many built-in functions, this is also an important reason why PHP can greatly improve development efficiency. There are many ways to obtain the element location in the array. among them, PHP itself has built in a function array_keys (), the following code can print all PHP built-in functions:
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)
?>