如何无序排列&从2行中回显2个随机单词?
示例我的代码
$lines1 = "one, two, three, four, five";
$lines2 = "aa, bb, cc, dd, ee";
$array=explode(",",$lines1, $lines2);
shuffle($array);
$newstring = implode($array,"");
echo substr($newstring, 0, 1);
$lines1
$lines2
原始字符串
来自line1
和line2
的2个字的回声选择性混洗
我想要这种
two
这个词来自line1
dd
这个词来自line2
输出two dd
或ee three
只需将这两行分解为seprate数组,然后对它们进行混洗。类似这样的东西:
$lines1 = "one, two, three, four, five";
$lines2 = "aa, bb, cc, dd, ee";
$array1 = explode(",", $lines1);
shuffle($array1);
$array2 = explode(",", $lines2);
shuffle($array2);
echo $array1[0] ." ". $array2[0];