How to randomly extract one or more units from an array _ PHP Tutorial

Source: Internet
Author: User
One or more units are randomly selected from the array. Array_rand () is used to randomly extract one or more units from an array. it is useful to retrieve one or more random units from an array. It uses input as the input number to randomly extract one or more units from the array. we will use array_rand (), it is useful to retrieve one or more random units from an array. It accepts input as an input array and an optional parameter num_req, specifying the number of units you want to retrieve-if not specified, the default value is 1. If you only retrieve one, array_rand () returns the key name of a random unit. Otherwise, an array containing the random key name is returned.

$ A = array ("a" => "dog", "B" => "cat", "c" => "horse ");
Print_r (array_rand ($ a, 1 ));
?>

Random () is useful when you want to extract one or more random units from an array. It accepts input as the input number...

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.