Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<ExamplesDs\Collection::clear>
^Data StructuresLast updated: Mon, 26 Oct 2026

The Collection interface

(PECL ds >= 1.0.0)

Introduction

Collection is the base interface which covers functionality common to all the data structures in this library. It guarantees that all structures are traversable, countable, and can be converted to json using json_encode().

Interface synopsis

interface Ds\Collection extends Countable, IteratorAggregate, JsonSerializable {
/* Methods */
public function clear(): void
public function copy(): Ds\Collection
public function isEmpty(): bool
public function toArray(): array
/* Inherited methods */
public function Countable::count(): int
}

Changelog

Version Description
PECL ds 1.4.0 Collection implements IteratorAggregate now instead of just Traversable. (This change came to the polyfill in 1.4.1.)

Table of Contents


<ExamplesDs\Collection::clear>
^Data StructuresLast updated: Mon, 26 Oct 2026