PHP array_key_exists How to check if a key name or index exists in an array, arraykeyexists_php tutorial

Source: Internet
Author: User

PHP Array_key_exists An implementation method that checks whether a key name or index exists in an array, arraykeyexists


Array_key_exists ()

The PHP array_key_exists () function is used to check if the given key name or index exists in the array and returns TRUE if one exists, otherwise FALSE.

Grammar:

the bool Array_key_exists (mixed key, array search) parameter key is the given key name or index and can be any value that can be indexed as an array.

The Array_key_exists () function is also available for objects.

Example:

<?php$arr_a = array (' id ' = = 1, ' name ' = ' "admin"), if (array_key_exists (' name ', $arr _a)) {  echo ' key name exists in array $ In the Arr_a ';} else {  echo ' key name does not exist in array $arr _a ';}? >

The example output is as follows:

The key name name exists in the array $arr _a array_key_exists () function returns TRUE for array elements whose value is null. To check if the array element is NULL, use Isset ().

The above PHP array_key_exists check whether the key name or index exists in the array implementation method is small to share all the content of everyone, I hope to give you a reference, but also hope that we have a lot of support to help guests home.

http://www.bkjia.com/PHPjc/1136644.html www.bkjia.com true http://www.bkjia.com/PHPjc/1136644.html techarticle php array_key_exists to check if the key name or index exists in the array, arraykeyexists array_key_exists () PHP array_key_exists () function is used to check the given key name or index ...

  • Related Article

    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.