Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,971 questions

51,913 answers

573 users

How to shuffle an array in PHP

1 Answer

0 votes
$arr = ["c++", "c", "javascript", "php", "java", "python"];

sort($arr);
print_r($arr);

shuffle($arr);
print_r($arr);


 
 
/*
run:
 
Array
(
    [0] => c
    [1] => c++
    [2] => java
    [3] => javascript
    [4] => php
    [5] => python
)
Array
(
    [0] => c++
    [1] => java
    [2] => c
    [3] => javascript
    [4] => python
    [5] => php
)

*/

 



answered Sep 30, 2021 by avibootz

Related questions

1 answer 140 views
140 views asked Mar 2, 2019 by avibootz
2 answers 143 views
143 views asked Nov 8, 2023 by avibootz
1 answer 102 views
102 views asked Jan 4, 2023 by avibootz
1 answer 88 views
88 views asked Jan 4, 2023 by avibootz
1 answer 195 views
195 views asked Oct 31, 2021 by avibootz
...