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

(PHP 5, PHP 7, PHP 8)


소개

이 클래스를 사용하면 객체가 배열로 작동할 수 있습니다.


클래스 개요

                  
class ArrayObject implements IteratorAggregate, 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, string $iteratorClass = ArrayIterator::class)
  public append(mixed $value): void
  public asort(int $flags = SORT_REGULAR): bool
  public count(): int
  public exchangeArray(array|object $array): array
  public getArrayCopy(): array
  public getFlags(): int
  public getIterator(): Iterator
  public getIteratorClass(): string
  public ksort(int $flags = SORT_REGULAR): bool
  public natcasesort(): bool
  public natsort(): bool
  public offsetExists(mixed $key): bool
  public offsetGet(mixed $key): mixed
  public offsetSet(mixed $key, mixed $value): void
  public offsetUnset(mixed $key): void
  public serialize(): string
  public setFlags(int $flags): void
  public setIteratorClass(string $iteratorClass): void
  public uasort(callable $callback): bool
  public uksort(callable $callback): bool
  public unserialize(string $data): void
}
                  
                

미리 정의된 상수


ArrayObject Flags

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

목차