php function Shuffle () implementation reordering _php Tutorial

Source: Internet
Author: User
Tags shuffle
In

Shuffle--The array is scrambled:
BOOL Shuffle (array &array)

php function Shuffle () An array of scrambled (randomly arranged cells).

Note: The PHP function shuffle () assigns a new key name to the cells in the array. This will delete the original key name and not just reorder it.

Example:

 
 
  1. < ? PHP
  2. $ a = Array (
  3. ' 1 ' = > ' Xiao ',
  4. ' 2 ' = > ' Da ',
  5. ' 3 ' = > ' Zuo ',
  6. ' 4 ' = > ' You '
  7. );
  8. echo "original array:". " < br />";
  9. Print_r ($a);
  10. Shuffle ($a);
  11. echo " < br />"." Now the array: "." < br />";
  12. Print_r ($a);
  13. ?>

Look at the results of the PHP function shuffle ():

The original array:

Array ([1] = Xiao [2] = Da [3] = Zuo [4] = =--)

Now the array:

Array ([0] = Da [1] = Xiao [2] = = [3] = = Zuo)

Of course, each time the page is refreshed, the order of the elements in the "now array" is changed once. Note that the key name of the array has changed.


http://www.bkjia.com/PHPjc/446075.html www.bkjia.com true http://www.bkjia.com/PHPjc/446075.html techarticle in Shuffle--the array is scrambled: the bool Shuffle (array array) PHP function shuffle () disrupts (randomly arranges the order of the cells) an array. Note: The PHP function Shuffle () is a unit in the array ...

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