ArrayObject::offsetExists

(PHP 5, PHP 7, PHP 8)

ArrayObject::offsetExistsReturns whether the requested index exists

Beschreibung

publicArrayObject::offsetExists(mixed$key): bool

Parameter-Liste

key

The index being checked.

Rückgabewerte

true if the requested index exists, otherwise false

Beispiele

Beispiel #1 ArrayObject::offsetExists() example

<?php
$arrayobj
= new ArrayObject(array('zero', 'one', 'example'=>'e.g.'));
var_dump($arrayobj->offsetExists(1));
var_dump($arrayobj->offsetExists('example'));
var_dump($arrayobj->offsetExists('notfound'));
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

bool(true) bool(true) bool(false)
To Top