표준 PHP 라이브러리(SPL) The ArrayIterator class

(PHP 5, PHP 7, PHP 8)


소개

이 반복자는 배열 및 개체를 반복하는 동안 값과 키를 설정 해제하고 수정할 수 있습니다.

동일한 배열을 여러 번 반복하려면 ArrayObject를 인스턴스화하고 foreach를 사용하거나 getIterator() 메서드를 수동으로 호출하여 이를 참조하는 ArrayIterator 인스턴스를 생성하도록 해야 합니다.


클래스 개요

                  
class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Countable {

  /* Constants */
  const int STD_PROP_LIST = 1;
  const int ARRAY_AS_PROPS = 2;

  /* Methods */
  public __construct(array|object $array = [], int $flags = 0)
  public append(mixed $value): void
  public asort(int $flags = SORT_REGULAR): bool
  public count(): int
  public current(): mixed
  public getArrayCopy(): array
  public getFlags(): int
  public key(): string|int|null
  public ksort(int $flags = SORT_REGULAR): bool
  public natcasesort(): bool
  public natsort(): bool
  public next(): void
  public offsetExists(mixed $key): bool
  public offsetGet(mixed $key): mixed
  public offsetSet(mixed $key, mixed $value): void
  public offsetUnset(mixed $key): void
  public rewind(): void
  public seek(int $offset): void
  public serialize(): string
  public setFlags(int $flags): void
  public uasort(callable $callback): bool
  public uksort(callable $callback): bool
  public unserialize(string $data): void
  public valid(): bool
}
                  
                

미리 정의된 상수


ArrayIterator Flags

ArrayIterator::STD_PROP_LIST
개체의 속성은 목록(var_dump, foreach 등)으로 액세스할 때 정상적인 기능을 갖습니다.
ArrayIterator::ARRAY_AS_PROPS
항목은 속성(읽기 및 쓰기)으로 액세스할 수 있습니다.

목차