array_keys returns some or all key names in the array
Description
array array_keys (array $array [, mixed $search_value [, bool $strict = false ]] )
array_keys() Returns the key name of the number or string in the $array array.
If the optional parameter search_value is specified, only the key name of the value will be returned. Otherwise all keys in the $array array will be returned.
Parameter details
Return value
Returns all keys in the array.
Example
<?php $array = array( 0 => 100 , "color" => "red" ); print_r ( array_keys ( $array )); $array = array( "blue" , "red" , "green" , "blue" , "blue" ); print_r ( array_keys ( $array , "blue" )); $array = array( "color" => array( "blue" , "red" , "green" ), "size" => array( "small" , "medium" , "large" )); print_r ( array_keys ( $array )); ?>
The above routine will output:
Array ( [0] => 0 [1] => color ) Array ( [0] => ; 0 [1] => 3 [2] => 4 ) Array ( [0] => color [1] => size )
Thank you for reading, I hope it can help everyone, thank you Thank you for your support of this site!
For more articles related to php array_keys returning the key name of the array, please pay attention to the PHP Chinese website!