Introduction
In this article I describe the PHP array functions array_key_exists, array_keys and array_map. To learn some other math functions, go to:
- Array Functions in PHP: PART 1
- Array Functions in PHP: PART 2
- Array Functions in PHP: PART 3
- Array Functions in PHP: PART 4
- Array Functions in PHP: PART 5
- Array Functions in PHP: PART 6
PHP array_key_exists Function
The PHP array_key_exists function deterimes whether the specified key or index exists in the given array or not and returns true if it exists otherwise false.
Syntax
| array_key_exists(key, array) |
Parameters
The parameters of the array_key_exists function are:
| Parameter | Description |
| key | It specifies key. |
| array | It specifies an array. |
Example
An example of the array_key_exists function is:
<?php
echo "<pre>";
$val = array("a" => "Apple", "b" => "Mango", "c" => "Orange", "Banana");
if(array_key_exists("a",$val))
{
echo "Key exists!";
}
else
{
echo "key does not exists!";
}
?>
Output
PHP array_keys Function
The PHP array_keys function accepts an array and returns a new array that contains only its keys.
Syntax
| array_keys(array,values) |
Parameters
The parameters of the array_keys function are:
| Parameter | Description |
| array | It specifies an array. |
| values | It specifies values, then only keys with this values are returned. |



Join the conversation! Your thoughts help the community grow.