这是我的阵列:
$my_array = array("1", "2", "3", "4", "5");如何在使用shuffle($my_array)和array_pop($my_array)后返回已删除的项
我想要这样的东西:被删除的号码是:3。
这是我的密码:
$my_array = array("1", "2", "3", "4", "5");
shuffle($my_array)
array_pop($my_array)我怎样才能做到这一点?
发布于 2019-04-23 00:09:19
根据PHP文档,pop()将返回已删除的值:
Return Values
Returns the value of the last element of array. If array is empty (or is not an array), NULL will be returned.因此,您可以简单地这样做::
$my_array = array(1, 2, 3, 4, 5);
shuffle($my_array);
echo 'The deleted number is: <b>'.array_pop($my_array).'</b>';https://stackoverflow.com/questions/55802563
复制相似问题