php8.5
Home/ Manual/ spl / arrayiterator/ ArrayIterator::offsetUnset

ArrayIterator::offsetUnset

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Unset value for an offset

Description

ArrayIterator::offsetUnset(mixed $key): void

Unsets a value for an offset.

If iteration is in progress, and ArrayIterator::offsetUnset is used to unset the current index of iteration, the iteration position will be advanced to the next index. Since the iteration position is also advanced at the end of a Foreach loop body, use of ArrayIterator::offsetUnset inside a foreach loop may result in indices being skipped.

Parameters

key

The offset to unset.

Return Values

Void

See Also

  • ArrayIterator::offsetGet
  • ArrayIterator::offsetSet

Source: reference/spl/arrayiterator/offsetunset.xml · from the official PHP manual (php/doc-en)