可变内容以随机顺序排列

Mas*_*Mas 1 php

每次刷新或访问页面时,我都希望此PHP变量的内容按随机顺序排列.

$test = 'a, b, c, d, e, f';
Run Code Online (Sandbox Code Playgroud)

我想要最好的方法来随机获取它,例如

$test = 'c, b, d, f, a, e';

$test = 'd, e, c, a, f, b';
Run Code Online (Sandbox Code Playgroud)

有解决方案吗

Nea*_*eal 6

$test = 'a, b, c, d, e, f';
$testArray = explode(', ',$test); //explode to array

shuffle($testArray); //shuffle it up

echo implode(', ', $testArray); //show the shuffledlyness
Run Code Online (Sandbox Code Playgroud)