PHP gets the position of an element in an array and the array_keys function is applied
- 2020-05-27 04:37:35
- OfStack
As we all know, PHP has many built-in functions, which is one of the important reasons that using PHP can greatly improve the development efficiency. There are many ways to get the position of the 1 element in an array, among which PHP itself has a built-in function array_keys(). The following code can print out all the built-in functions of PHP:
The syntax for array_keys is as follows:
Where strict is set to true to trigger the strict matching mode of data type validation, the default is false. The following code shows a simple application of array_keys.
<?php
print_r(get_defined_functions());
?>
The syntax for array_keys is as follows:
array_keys(array,value,[strict])
Where strict is set to true to trigger the strict matching mode of data type validation, the default is false. The following code shows a simple application of array_keys.
<?php
$test=array(10,20,30,"10","20","30");
print_r(array_keys($test,"10",true));// Strict matching pattern
// Output:
//Array ( [0] => 3)
?>