Randomly disrupt the array and test the use of string PHP functions

Source: Internet
Author: User
Randomly disrupt the array, string PHP function application test & nbsp; website construction www.ucantech.com & lt ;? Php & nbsp;/** & nbsp; * random disrupt array, string PH Random disrupt array, string PHP function application test
Website construction www.ucantech.com /**
* Random disruption to the array and string PHP function application test
*
* @ Author flyer0126
* @ Date 2011-12-29
*
*/

// Randomly disrupt the array
$ Arr = array ('1', '2', '3', '4', '5', '6 ');

Print_r ($ arr );
// Array ([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6)
Shuffle ($ arr );

Print_r ($ arr );
// Array ([0] => 3 [1] => 4 [2] => 1 [3] => 2 [4] => 6 [5] => 5)


// Randomly disrupt the string
$ Str = 'abcdef ';

Echo $ str;
// Abcdef

$ Stred = str_shuffle ($ str );

Echo $ stred;
// Dbafec

?> Fblww-0102)

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.