HH\Set::toArray

Returns an array containing the values from the current Set

Description

public function toArray(): array<Tv, Tv>

For the returned array, each key is the same as its associated value.

Return Values

Examples

<?hh

namespace Hack\UserDocumentation\API\Examples\Set\ToArray;

function run() {
  $s = Set {'red', 'green', 'blue', 'yellow'};

  $array = $s->toArray();

  var_dump(is_array($array));
  var_dump($array);
}

run();
Output
bool(true)
array(4) {
  ["red"]=>
  string(3) "red"
  ["green"]=>
  string(5) "green"
  ["blue"]=>
  string(4) "blue"
  ["yellow"]=>
  string(6) "yellow"
}