ArrayObject::offsetExists
PHP Manual
PHP Manual»ArrayObject»ArrayObject::offsetExists

ArrayObject::offsetExists

(PHP 5, PHP 7, PHP 8)

ArrayObject::offsetExistsReturns whether the requested index exists

Descrizione

public function ArrayObject::offsetExists(mixed $key): bool

Elenco dei parametri

key

The index being checked.

Valori restituiti

true if the requested index exists, otherwise false

Esempi

Example #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'));
?>

Il precedente esempio visualizzerà:

bool(true)
bool(true)
bool(false)

To Top