note 104430 modified in function.shuffle by danbrown
| From: | danbrown@php.net | Date: | Wed, 15 Jun 2011 16:52:00 +0000 |
| Subject: | note 104430 modified in function.shuffle by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180563@lists.php.net to get a copy of this message | ||
Very simple shuffle function preserving key with value
<?php
function shuffle_assoc( $array )
{
$keys = array_keys( $array );
shuffle( $keys );
return array_merge( array_flip( $keys ) , $array );
}
?>
--was--
// Very simple shuffle function preserving key with value
function shuffle_assoc( $array )
{
$keys = array_keys( $array );
shuffle( $keys );
return array_merge( array_flip( $keys ) , $array );
}
http://php.net/manual/en/function.shuffle.php