The PHP array function is a key point, because in PHP is a major composite data type,
The first is to look for a value whether there is a function in an array:
array_search- searches for the given value in the array, and returns the corresponding key name if successful
mixed array_search ( mixed $needle , array $haystack [, bool $strict ])
<?php$array = Array (0 = ' Blue ', 1 = ' red ', 2 = ' green ', 3 = ' red '); $key = Array_search (' green ', $array) ; $key = 2; $key = Array_search (' red ', $array);
If you need to relate to TRUE or false, use this function with caution, because if the first bit of the value is satisfied, it is possible to return the key value 0, which is false, it does not set
in_array- Checks if a value exists in the array
BOOL In_array ( mixed $needle , array $haystack [, bool $strict ])
<?php$os = Array ("Mac", "NT", "Irix", "Linux"), if (In_array ("Irix", $os)) { echo "Got Irix";} if (In_array ("Mac", $os)) {
The occasional problem with this function is a case-sensitive problem,
Array_key_existsbool array_key_exists ( mixed $key , array $search )
<?php$search_array = Array (' first ' = = 1, ' second ' = 4); if (array_key_exists (' first ', $search _array)) { echo "The ' first ' element is in the array";}? >
PHP Array function correlation