Php-Arrays function-array_key_exists-check whether the given key name or index exists in the array

Source: Internet
Author: User

Array_key_exists () checks whether the given key name or index exists in the array.

[Function]
This function returns a Boolean value,
If the specified key exists in the specified array, true is returned; otherwise, false is returned.
This function can also be used to check whether the specified key is in the object.
Scope of use]
Php4> 4.1.0, php5.
[Use]
Bool array_key_exists (mixed key, array search)
Key/required/key name
Search/required/search Array
[Example]
[Php]
<? Php
$ Search_array = array ('first' => 1, 'second' => 4 );
If (array_key_exists ('first', $ search_array )){
Echo "The 'first' element is in the array ";
}
/*
The 'first' element is in the array
*/

 

Taken from zuodefeng's note

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.