current position:Home>The PHP array random sorting function shuffle() randomly scrambles the order of array elements

The PHP array random sorting function shuffle() randomly scrambles the order of array elements

2022-04-29 16:05:37Lingering memory of Yufei

php Array random sorting function shuffle Randomly disorder the order of array elements

shuffle() function

bool shuffle ( array &$arr )

Parameters arr Represents an array .

shuffle() After the function call , arr The order of array elements will be disrupted .

Return value : Return on success TRUE, Return... On failure FALSE.

<?php

$old_number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

echo " Before ordering <pre>";
print_r($old_number);

shuffle($old_number);

echo " After ordering <pre>";
print_r($old_number);

?>

 Insert picture description here

copyright notice
author[Lingering memory of Yufei],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291425561721.html

Random recommended