我是php的新手,正在尝试一些不同的东西。我从乘以值的字符串中打印随机值时遇到问题。
$list = "the weather is beautiful tonight".
$random = one random value from $list, for example "beautiful" or "is"
有没有简单的方法可以做到这一点?谢谢!
// First, split the string on spaces to get individual words
$arg = explode(' ',"the weather is beautiful tonight");
// Shuffle the order of the words
shuffle($arg);
// Display the first word of the shuffled array
print $arg[0];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句