The following code is exactly what should be written
$a = "' 111 ', ' 222 ', ' 333 ', ' 1111 ', ' 2222 ', ' 3333 ', ' 1112 ', ' 2221 ', ' 33313 ', ' 1114 ', ' 2225 ', ' 3336 '";
echo $a;
Srand (float) microtime () * 10000000);
$input = array ($a);
$rand _keys = Array_rand ($input, 10);
echo $input [$rand _keys[0]]. ', '. $input [$rand _keys[1]]. ', '. $input [$rand _keys[2]]. ', '. $input [$rand _keys[2]]. ', '. $ input[$rand _keys[4]]. ', '. $input [$rand _keys[5]]. ', '. $input [$rand _keys[6]]. ', '. $input [$rand _keys[7]]. ', '. $input [ $rand _keys[8]]. ', '. $input [$rand _keys[9]];
Srand (float) microtime () * 10000000);
$input = Array (' 111 ', ' 222 ', ' 333 ', ' 1111 ', ' 2222 ', ' 3333 ', ' 1112 ', ' 2221 ', ' 33313 ', ' 1114 ', ' 2225 ', ' 3336 ');
$rand _keys = Array_rand ($input, 10);
echo $input [$rand _keys[0]]. ', '. $input [$rand _keys[1]]. ', '. $input [$rand _keys[2]]. ', '. $input [$rand _keys[2]]. ', '. $ input[$rand _keys[4]]. ', '. $input [$rand _keys[5]]. ', '. $input [$rand _keys[6]]. ', '. $input [$rand _keys[7]]. ', '. $input [ $rand _keys[8]]. ', '. $input [$rand _keys[9]];
Why the above code is wrong, the following code is correct?
What is the correct way to write the above paragraph, please?
Know the master please direct to the code, thank you
Share to: more
------Solution--------------------
$a = "' 111 ', ' 222 ', ' 333 ', ' 1111 ', ' 2222 ', ' 3333 ', ' 1112 ', ' 2221 ', ' 33313 ', ' 1114 ', ' 2225 ', ' 3336 '";
echo $a;
Srand (float) microtime () * 10000000);
$input = eval ("Return array ($a);"); Watch this.
$rand _keys = Array_rand ($input, 10);
echo $input [$rand _keys[0]]. ', '. $input [$rand _keys[1]]. ', '. $input [$rand _keys[2]]. ', '. $input [$rand _keys[2]]. ', '. $ input[$rand _keys[4]]. ', '. $input [$rand _keys[5]]. ', '. $input [$rand _keys[6]]. ', '. $input [$rand _keys[7]]. ', '. $input [ $rand _keys[8]]. ', '. $input [$rand _keys[9]];