05-07-2008, 12:07 PM
|
#10 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
sketch, your first code snippet has an off-by-one error related to the $cnt variable. It needs to be count()-1 for the loops and calls to rand else you'll get " Undefined offset" notices.
Also, what's the harm in using something like the following instead of the longer, looping code snippet?
PHP Code:
$words = 'I took my dog for a walk';
$shuffled = explode(' ', $words);
shuffle($shuffled);
echo implode(' ', $shuffled);
|
|
|
|