PHP key array | Fetch a key from an array in PHP

The key() function is used to fetch a key from an array.

Syntax
key(array)

Example:


<?php
$arr1 = array('A=>0','B=>1');
echo key($arr1); 
?>


Output:
A,B