The Ds\Set::toArray()
function in PHP is used to convert a set into an array.
The toArray()
function can be declared as shown in the code snippet below:
public array Ds\Set::toArray( void )
The toArray()
converts a set into an array and returns the array.
Consider the code snippet below, which demonstrates the use of the toArray()
function.
<?php$objSet = new \Ds\Set([0, 2, 4, 6]);// Corresponding array isecho "Array is:\n";print_r($objSet->toArray());?>
We declare a set objSet
in line 3. We use the toArray()
function in line 7 to convert objSet
to an array.