The ArrayObject class

(PHP 5, PHP 7, PHP 8)

简介

This class allows objects to work as arrays.

类摘要

classArrayObjectimplementsIteratorAggregate, ArrayAccess, Serializable, Countable {
public__construct(array|object$array = [], int$flags = 0, string$iteratorClass = ArrayIterator::class)
publicappend(mixed$value): void
publicasort(int$flags = SORT_REGULAR): true
publiccount(): int
publicgetFlags(): int
publicksort(int$flags = SORT_REGULAR): true
publicnatcasesort(): true
publicnatsort(): true
publicoffsetExists(mixed$key): bool
publicoffsetGet(mixed$key): mixed
publicoffsetSet(mixed$key, mixed$value): void
publicoffsetUnset(mixed$key): void
publicserialize(): string
publicsetFlags(int$flags): void
publicsetIteratorClass(string$iteratorClass): void
publicuasort(callable$callback): true
publicuksort(callable$callback): true
publicunserialize(string$data): void
}

预定义常量

ArrayObject Flags

ArrayObject::STD_PROP_LIST

Properties of the object have their normal functionality when accessed as list (var_dump(), foreach, etc.).

ArrayObject::ARRAY_AS_PROPS

Entries can be accessed as properties (read and write). The ArrayObject class uses its own logic to access properties, thus no warning or error is raised when trying to read or write dynamic properties.

目录

To Top