Isset vs array_key_exists

Isset vs array_key_exists

isset
- It is language construct, not a function
- It is used to find whether variables are set or not.

array_key_exists
This function is used to check whether key exists in an array

Example:

$arr = array(1=>0,2=>”two”);

print_r($arr);

echo isset($arr[1]);

echo array_key_exists(1,$arr);

In the above example isset and array_key_exists,both will return 1. But isset is a language construct, so it should be faster that array_key_exists

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.