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
?>
PHP.mk документација
SplFixedArray::offsetUnset
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
splfixedarray.offsetunset.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + превод во позадина
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
splfixedarray.offsetunset.php
SplFixedArray::offsetUnset
Референца за `splfixedarray.offsetunset.php` со подобрена типографија и навигација.
SplFixedArray::offsetUnset
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
SplFixedArray::offsetUnset — Unsets the value at the specified $index
Параметри
index-
Индексот што се брише.
Вратени вредности
Не се враќа вредност.
Errors/Exceptions
). Ако повикот не успее, ќе врати RuntimeException when index is outside the defined size of the array or when index не може да се парсира како цел број.
Белешки од корисници 1 белешка
c точка 1 на smithies точка org ¶
пред 15 години