access arraye key from null not make error php code example
Example 1: get key by value array php
<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;
?>
Example 2: php array all keys empty
array('key1' => null, 'key2' => null, 'key3' => null, 'key4' => null)
if (!array_filter($array)) {
// all values are empty (where "empty" means == false)
}