©
本文档使用 PHP中文网手册 发布
(PHP 5 >= 5.3.0)
SplFixedArray::offsetExists — Returns whether the requested index exists
$index
)
Checks whether the requested index index
exists.
index
The index being checked.
TRUE
if the requested index
exists, otherwise FALSE
[#1] depoemarc at swap dot fn dot ln dot googlemail dot com [2015-06-25 14:47:01]
It should be noted that offsetExists behaves like "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)); // true
unset($arr[1]); // $arr->offsetUnset(1);
var_dump($arr->offsetExists(1)); // false
var_dump($arr);
?>