gpt4 book ai didi

PHP rand() 排除某些数字

转载 作者:可可西里 更新时间:2023-10-31 22:06:23 26 4
gpt4 key购买 nike

我有这个:

<?php  $n = rand(1,1600); echo $n ?>

我想从随机数中排除 234、1578、763、1274 和其他数字。我该怎么做?

最佳答案

<?php

while( in_array( ($n = mt_rand(1,1600)), array(234, 1578 ,763 , 1274) ) );

关于PHP rand() 排除某些数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17109465/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com