Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

array key exists function syntax tag tutorial 2013 Donate at flattr Flattr this





Alert! Connect with 10,000 Chating Online. Join Now

Php array key exists () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 4 >= 4.1.0, PHP 5)

array_key_exists -- Checks if the given key or index exists in the array

Syntax

bool array_key_exists ( mixed key, array search )

array_key_exists() returns TRUE if the given key is set in the array. key can be any value possible for an array index. array_key_exists() also works on objects.

Example 1. array_key_exists() example

<?php
$search_array
= array('first' => 1, 'second' => 4);
if (
array_key_exists('first', $search_array)) {
    echo
"The 'first' element is in the array";
}
?>

Note: The name of this function is key_exists() in PHP 4.0.6.

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.

<?php
$search_array
= array('first' => null, 'second' => 4);

// returns false
isset($search_array['first']);

// returns true
array_key_exists('first', $search_array);
?>

See also isset(), array_keys(), and in_array().

Php array key exists Function syntax tag

array key exists php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php array key exists syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online