PHP Shuffle functions

Source: Internet
Author: User
Tags shuffle

Definition and usage

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.

Grammar

Shuffle (Array)
Parameters Description
Array Necessary. Specifies the array to use.

Example

!--? Php$my_array = Array (" A "=-->" Dog "," b "=" Cat "," c "=" Horse "); SHUFFL E ($my _array);p rint_r ($my _array);? 

Output:

array ([0] = Cat [1] = Horse [2] = Dog) 

Above Introduced the PHP shuffle function, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.