fillKeys()

The fillKeys() method fills an array with the static value, using the values of the array as keys.

Example.php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["first", "second", "third"]);

//Fill keys with 0
$arrayUtils->fillKeys(0);
// expected output: ["first" => 0, "second" => 0, "third" => 0]

Syntax

$arrayUtils->fillKeys(mixed $value) : ArrayUtils;

Parameter

  • $value

    Value to fill the array with.

Return value

  • A filled array.

Prefixing

$arrayUtils->fillKeysAs(mixed $value) : array;
ArrayUtils::fillKeysFrom(iterable $from, mixed $value) : ArrayUtils;
ArrayUtils::fillKeysFromAs(iterable $from, mixed $value) : array;

References

Last updated