Skip to content

Kirby 5.5.0

A::flip()

Inverts the given array into a multimap of value → keys. Values may be scalar (a single key) or arrays (each element becomes its own key in the result). Unlike PHP's array_flip(), duplicate values are preserved: every original key that maps to the same value ends up in the resulting list.

A::flip(array $array): array

Parameters

Name Type Default
$arrayrequired array no default value

Return type

array

Parent class

Kirby\Toolkit\A

Examples

$array = [
  'apple'      => ['red', 'green'],
  'strawberry' => 'red',
  'banana'     => 'yellow',
  'kiwi'       => 'green',
];