Core Function Flip

From Sputnik Wiki
Jump to: navigation, search
Flip( <array> )

Contents

Description

Exchanges all keys with their associated values in an array

Parameters

array

The array to use.

Return Value

Success: Returns new array.

Failure: Returns 0.

Remarks

Returns an array in flip order, i.e. keys from trans become values and values from trans become keys.

Note that the values of need to be valid keys, i.e. they need to be either integer or string.

If a value has the wrong type the key/value pair in question will not be included in the result.

Example

$array = array( "Cat" => "Meow", "Dog" => "Woof", "Cow" => "Moo" );
 
echo "Before flip:\n";
printr $array;
 
$array = flip $array;
 
echo "After flip:\n";
printr $array;
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox