Link | array_shuffle |
Author | Jason Huck |
Category | Array |
Version | 8.x |
License | |
Posted | 24 Oct 2005 |
Updated | 24 Oct 2005 |
More by this author... |
Returns the given array in a new, random order.
var('orderedItems') = array(1,2,3,4,5); var('shuffledItems') = array_shuffle($orderedItems); $orderedItems; // -> array: (3),(2),(1),(5),(4)
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( 'shuffle', -namespace='array_', -priority='replace', -description='Returns the given array in a new, random order.' ); fail_if( !params->size || !params->first->isa('array'), -1, '[array_shuffle] requires an array as a parameter.' ); local( 'in' = params->first, 'out' = array ); #out->reserve(#in->size); while(#in->size); local('x') = math_random( -lower=1, -upper=#in->size ); #out->insert(#in->get(#x)); #in->remove(#x); /while; return(#out); /define_tag;
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
I love tagswap