Check if requested index exists in an array ArrayObject::offsetExists in PHP

Description

The following code shows how to check if requested index exists in an array ArrayObject::offsetExists.

Example


<?php/*w w  w  .j  ava  2 s .c o  m*/
$arrayobj = new ArrayObject(array('0', 'one', 'example'=>'e.g.'));
var_dump($arrayobj->offsetExists(1));
var_dump($arrayobj->offsetExists('example'));
var_dump($arrayobj->offsetExists('notfound'));
?>

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