Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您可以使用“rand”生成随机运算符吗?我制作了一个 php 程序来将两个随机数相加,但我想改变它并使运算符随机化。使用“rand”是最好的方法。谢谢
好吧,您可以将运算符放在一个数组中,然后调用 array_rand 来检索它
$ops = array('+','-','*','/'); $rand_key = array_rand($ops); $operator =- $ops[$rand_key];
可能你可以使用随机和圆形并切换结构