flip()

The flip() method exchanges all keys with their values in an array

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

$arrayUtils = ArrayUtils::from(["a", "b", "c", "d"]);

//General usage
$arrayUtils->flip();
// expected output: ["a" => 0, "b" => 1, "c" => 2, "d" => 3]

Syntax

$arrayUtils->flip() : ArrayUtils;

Return value

  • A flipped array on success and NULL on failure.

Prefixing

$arrayUtils->flipAs() : array;
ArrayUtils::flipFrom(iterable $from) : ArrayUtils;
ArrayUtils::flipFromAs(iterable $from) : array;

References

Last updated