Home  >  Article  >  Backend Development  >  PHP gets the position of an element in the array and application of array_keys function_PHP tutorial

PHP gets the position of an element in the array and application of array_keys function_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:13:171211browse

As we all know, PHP itself has many built-in functions, which is also an important reason why using PHP can greatly improve development efficiency. There are many ways to obtain the position of an element in an array, among which PHP itself has a built-in function array_keys(), as shown below The code can print out all PHP's built-in functions:

Copy the code The code is as follows:

print_r (get_defined_functions());
?>

The syntax of array_keys is as follows:
Copy code The code is as follows:

array_keys(array,value,[strict])

where strict is set to true to trigger the strict matching mode of data type verification, the default is false, the code below Shows a simple application of array_keys.
Copy code The code is as follows:

$test=array(10,20,30, "10","20","30");
print_r(array_keys($test,"10",true));//Strict matching mode
//Output:
//Array ( [0] => 3)
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326517.htmlTechArticleAs we all know, PHP itself has many built-in functions, which is also an important reason why using PHP can greatly improve development efficiency. There are many ways to get the position of an element in an array, among which PHP has...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn