Home > Article > Backend Development > PHP array introductory tutorial array_key_exists() function
This article introduces the usage of the array_key_exists() function of the PHP array function. Friends in need can refer to it.
In the php array function, the function array_key_exists() implements this function: Returns true if a specified key is found in an array, false otherwise. The form is as follows: boolean array_key_exists(mixed key,array array); Example, search for apple in the array key, if found, the color of this fruit will be output: <?php //array_key_exists函数用法举例 //by bbs.it-home.org $fruit["apple"] = "red"; $fruit["banana"] = "yellow"; $fruit["pear"] = "green"; if(array_key_exists("apple", $fruit)){ printf("apple's color is %s",$fruit["apple"]); } //apple's color is red ?> |