Random number generation of arrays in PHP

Source: Internet
Author: User
This article introduces the content of the PHP array of random number generation, has a certain reference value, now share to everyone, the need for friends can refer to

<?php//Array_rand (); Randomly remove one or more cells from an array//if the Array_rand does not write the length parameter or the parameter is 1, the return is not an array, but an integer of type int, such as the next Var_dump, In this case, assigning a value to the variable Array_merge will give an error. Var_dump (Array_rand (range (0,9), $length));//Array_flip (); Swaps the keys and values in the array/range (); Creates an array from the range that contains the specified element//shuffle-scrambled array, Returns a Boolean value that is not suitable for this case $merge=array_rand (Array_flip (Array_merge (range (' A ', ' Z '), Range (0,9)), 4);p Rint_r ($merge);?>
<?php//join (', $array) an array with an empty connection and returns a string, and join is the alias of implode $str=join ("', Array_rand (Array_flip (Array_merge (' a ') , ' Z '), Range (0,9)), 4); Var_dump ($STR);?>

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.