note 104367 modified in function.array-slice by danbrown

From: Date: Sat, 11 Jun 2011 13:58:27 +0000
Subject: note 104367 modified in function.array-slice by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180434@lists.php.net to get a copy of this message
I've found this useful. The following is a function used to shuffle a very specific part of the array, by providing start and end index. <?php function array_shuffle_section(&$a, $s, $e) { $head = array_slice($a, 0, $s); $body = array_slice($a, $s, $e-$s+1); $tail = array_slice($a, $e+1); shuffle($body); $a = array_merge($head,$body,$tail); } ?> --was-- I've found this useful. The following is a function used to shuffle a very specific part of the array, by providing start and end index. function array_shuffle_section(&$a, $s, $e) { $head = array_slice($a, 0, $s); $body = array_slice($a, $s, $e-$s+1); $tail = array_slice($a, $e+1); shuffle($body); $a = array_merge($head,$body,$tail); } http://php.net/manual/en/function.array-slice.php

« previous php.notes (#180434) next »