Organizational Research By

Surprising Reserch Topic

Question:how to Checks if the given key or index exists in the array using php?



asked Sep 13, 2013 in PHP by rajesh
edited Sep 12, 2013
+1 vote
27 views



Related Hot Questions

1 Answer

0 votes

 

$search_array = array('first' => 1, 'second' => 4);
if (array_key_exists('first', $search_array)) {
    echo "The 'first' element is in the array";
}
?>
Example #2 array_key_exists() vs isset()
isset() does not return TRUE for array keys that correspond to a NULL value, while array_key_exists() does.
$search_array = array('first' => null, 'second' => 4);
 
// returns false
isset($search_array['first']);
 
// returns true
array_key_exists('first', $search_array);
?>
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013

...