Check if the key "XML" exists in an array in PHP

Description

The following code shows how to check if the key "XML" exists in an array.

Example


/*from   w w  w .  java  2s.  com*/
<?php
    $a=array("XML"=>"data","CSS"=>"style");
    if (array_key_exists("XML",$a)){
        echo "Key exists!";
    }else{
        echo "Key does not exist!";
    }
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone