[array_flip]

Description

Link: [array_flip]
Author: Jason Huck
Category: Array
Version: 8.x
License:
Posted: Jan. 16, 2006
Updated: Jan. 17, 2006
More by this author...
Lazy way to reverse the order of key/value pairs in a pair array.

Parameters

none


Sample Usage

var('unflipped') = array(
	'a' = 1,
	'b' = 2,
	'c' = 3
);

var('flipped') = array_flip($unflipped);

$flipped;

-> (array: (pair: 1 = a), (pair: 2 = b), (pair: 3 = c))
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
define_tag(
	'flip',
	-namespace='array_',
	-required='in',
	-type='array',
	-description='Returns the given pair array with the keys and values inverted.'
);
	local('out' = array);
	
	iterate(#in, local('i'));
		#out->insert(#i->second = #i->first);
	/iterate;
	
	return(#out);
/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular