Syntax
| bool array_key_exists ( $key, $array ); |
Definition and Usage
Returns TRUE if the given key is set in the array. key can be any value possible for an array index.
Paramters
| Parameter | Description |
|---|---|
| key | Required. Key to be searched. |
| array | Required. Array to be searched |
Return Values
Returns TRUE if the given key is set in the array otherwise FALSE.
Example
Try out following example:
<?php
$search_array = array('first' => 1, 'second' => 4);
if (array_key_exists('first', $search_array)) {
echo "The 'first' element is in the array";
}
?>
|
This will produce following result:
The 'first' element is in the array |
No comments:
Post a Comment