PHP从数组中取值后移除下次不再取到

我有个数组里面是[a,b,c]
随机获取一个值后,如a
下次数组只剩[b,c]
再从b,c里取,取完为止,求代码

如果问题得到解决,请点采纳,谢谢

<?php
$input = array("a", "b", "c", "d", "e");
shuffle($input);
$i = 1;
foreach ($input as $item) {
    echo "第".strval($i)."次取出".$item." ";
}
?>
<?php
$arr = [3, 4, 7, 8, 9];

function getNumber(&$arr)
{
    $len = count($arr);
    if ($len > 0) {
        $index = mt_rand(0, $len - 1);
        $value = $arr[$index];
        array_splice($arr, $index, 1);
        return $value;
    }
    return null;
}

while (true) {
    $value = getNumber($arr);
    if (null === $value) {
        break;
    }
    echo $value . "\n";
}
$data = ['a', 'b', 'c', 'd', 'e'];

while ($data && ($key = array_rand($data)) !== null) {
    var_dump($data[$key]);
    unset($data[$key]);
}