in array key php code example
Example 1: php key exists
$fruits = ['apple', 'pear', 'banana'];
if (array_key_exists("banana", $fruits)) {
}
$exists = array_key_exists("peach", $fruits);
Example 2: php key in array exists
<?php
$search_array = array('first' => null, 'second' => 4);
isset($search_array['first']);
array_key_exists('first', $search_array);
?>
Example 3: get key by value array php
<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array);
$key = array_search('red', $array);
?>