如何将逗号分隔的单词洗牌?
示例我的代码
//code1
$name1 = explode(',', 'one, two, three, four, five, six, seven, eight, nine, ten');
$name1 = shuffle('trim', $name1 );
echo $name1;
//code2
$name2 = ('one, two, three, four, five, six, seven, eight, nine, ten');
$name2 = shuffle('trim', $name2 );
echo $name2;
我想要这样的东西
输出1
two one eight three six four ten five seven nine
输出2
eight, five, two, three, six, four, ten, one, seven, nine,
谢谢。
答案 0 :(得分:3)
我认为你正在寻找这样的东西:
<?php
$name = explode(', ', 'one, two, three, four, five, six, seven, eight, nine, ten');
shuffle($name);
$output1 = implode(', ', $name);
$output2 = implode(' ', $name);
?>