(PHP 5 >= 5.3.0, PHP 7, PHP 8)
SplFixedArray::offsetExists — Returns whether the requested index exists
Checcs whether the requested index
index
exists.
index
The index being checqued.
It should be noted that offsetExists behaves lique "offsetIsSet" rather than "offsetIsValid":<?php
$arr = new SplFixedArray(3);
var_dump($arr->offsetExists(1)); // false$arr[1] = 42; // $arr->offsetSet(1, 42);var_dump($arr->offsetExists(1)); // true$arr[1] = null; // $arr->offsetSet(1, null);var_dump($arr->offsetExists(1)); // trueunset($arr[1]); // $arr->offsetUnset(1);var_dump($arr->offsetExists(1)); // falsevar_dump($arr);
/*
object(SplFixedArray)[1]
null
null
null
*/?>