Lasso Soft Inc. > Home

[array_flip]

Linkarray_flip
AuthorJason Huck
CategoryArray
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted16 Jan 2006
Updated17 Jan 2006
More by this author...

Description

Lazy way to reverse the order of key/value pairs in a pair array.

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.

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

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft