Mega Code Archive

 
Categories / Php / Data Type
 

Array shuffle

<?php    $cards = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P");    // shuffle the cards    print_r($cards);        print "<BR><BR><BR>";       shuffle($cards);    // Use array_chunk() to divide the cards into four equal "hands"    $hands = array_chunk($cards, 4);    print_r($hands); ?>