PHP Shuffle () array random sort code _php tutorial

Source: Internet
Author: User
Tags shuffle
The shuffle () function rearranges the elements in the array in random order.

Returns TRUE if successful, otherwise FALSE is returned.

Note: This function assigns the new key name to the cells in the array. This will delete the original key name and not just reorder it.

Note: Since PHP 4.2.0, it is no longer necessary to sow the random number generator with the Srand () or Mt_srand () function, which is now automatically completed

$my _array = Array ("A" = "Dog", "b" = "Cat", "c" = "Horse");
Shuffle ($my _array);
Print_r ($my _array);
?>
Here's A//use an array to store your ad list

$ads = Array (
,
,
,
);

Random Sorting of arrays
Shuffle ($ads);

Output a sorted array
$html =;
foreach ($ads as $ad) {
$html. = $ad;
}
Echo $html;



http://www.bkjia.com/PHPjc/478762.html www.bkjia.com true http://www.bkjia.com/PHPjc/478762.html techarticle The Shuffle () function rearranges the elements in the array in random order. Returns TRUE if successful, otherwise FALSE is returned. Note: This function assigns the new key name to the cells in the array. This ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.