HH\Map::toArray

Returns an array containing the key/value pairs from the current Map

Description

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

Return Values

Examples

<?hh

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

$m = Map {
  'red' => '#ff0000',
  'green' => '#00ff00',
  'blue' => '#0000ff',
  'yellow' => '#ffff00',
  'purple' => '#663399',
};

$array = $m->toArray();

var_dump(is_array($array));
var_dump($array);
Output
bool(true)
array(5) {
  ["red"]=>
  string(7) "#ff0000"
  ["green"]=>
  string(7) "#00ff00"
  ["blue"]=>
  string(7) "#0000ff"
  ["yellow"]=>
  string(7) "#ffff00"
  ["purple"]=>
  string(7) "#663399"
}