Shuffling Array Elements Randomly in PHP


Randomize the order of elements in an array using shuffle().

Source Code

$cards = [1, 2, 3, 4, 5];
shuffle($cards);
print_r($cards); // The order of $cards is now random
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments