php8.5
Home/ Manual/ ds / set/ Ds\Set::toArray

Ds\Set::toArray

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Converts the set to an Array

Description

Ds\Set::toArray(): array

Converts the set to an Array.

Note

Casting to an Array is not supported yet.

Parameters Parameters

Return Values

An Array containing all the values in the same order as the set.

Examples

Ds\Set::toArray() example

php
<?php
$set = new \Ds\Set([1, 2, 3]);

var_dump($set->toArray());
?>

The above example will output something similar to:

output
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

Source: reference/ds/ds/set/toarray.xml · from the official PHP manual (php/doc-en)