Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$title is deprecated in /home/www/dev/work/website/lvesu/class/controller/blog/php.php on line 28

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/php.manual.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\php::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
PHP - Manual: SplFixedArray::offsetUnset - 互联网笔记

略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: SplFixedArray::offsetUnset

2025-05-03

SplFixedArray::offsetUnset

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SplFixedArray::offsetUnsetUnsets the value at the specified $index

说明

public SplFixedArray::offsetUnset(int $index): void

Unsets the value at the specified index.

参数

index

The index being unset.

返回值

没有返回值。

错误/异常

Throws RuntimeException when index is outside the defined size of the array or when index cannot be parsed as an integer.

添加备注

用户贡献的备注 1 note

up
3
c dot 1 at smithies dot org
14 years ago
This function assigns NULL to the array element. Its use has no effect on count(). Whereas assigning NULL to an element will have no effect on isset(), offsetUnset() and unset() do. Whereas unsetting an element affects the behaviour of foreach() as applied to an array or an ArrayObject, it has no such effect on SplFixedArray, as demonstrated by the code below.

<?php

class atest extends SplFixedArray {
public function
fill() {
for (
$i = $this->count(); --$i >= 0; ) $this[$i] = $i;
}
public function
dump() {
$sep = ' ';
foreach (
$this as $k => $v) {
echo
$sep, "$k: ", (is_null($v) ? 'NULL' : $v);
if (!isset(
$this[$k])) echo ' and unset';
$sep = ', ';
}
echo
PHP_EOL;
}
}

$a = new atest(3);
$a->dump(); // 0: NULL and unset, 1: NULL and unset, 2: NULL and unset
$a->fill();
$a->dump(); // 0: 0, 1: 1, 2: 2
$a[1] = NULL;
unset(
$a[2]);
$a->dump(); // 0: 0, 1: NULL, 2: NULL and unset
?>

官方地址:https://www.php.net/manual/en/splfixedarray.offsetunset.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3