PHP array_keys() Function
Complete PHP Array Reference Manual
Example
Return a new array containing all the keys of an array:
"XC90","BMW"=>"X5","Toyota"=>"Highlander"); print_r(array_keys($a)); ?>Run Example »
Definition and Usage
The array_keys() function returns a new array containing all the keys of an array.
Syntax
array_keys(
array,value,strict
)
| Parameters | Description |
|---|---|
| array | Required. Specifies the array. |
| value | Optional. You can specify a value, and only the keys corresponding to that value will be returned. |
| strict | Optional. Used together with the value parameter. Possible values:
|
Technical Details
| Return Value: | Returns a new array containing all the keys of the array. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | strict This parameter was added in PHP 5.0. |
More examples
Example 1
Using the value parameter:
"XC90","BMW"=>"X5","Toyota"=>"Highlander"); print_r(array_keys($a,"Highlander")); ?>Run Example »
Example 2
Using the strict parameter (false):
Run Example »
Example 3
Using the strict parameter (true):
Run Example »
Complete PHP Array Reference Manual