What $codes?

on the penultimate line
<?php
$codes = array_merge(range(65, 90), range(97, 122));
 echo chr($codes[array_rand($codes)]);
?>
April 3rd 20 at 17:41
2 answers
April 3rd 20 at 17:43
Solution
array_merge()
range()
array_rand()

To create an array of the numbers 65 to 90 and 97 through 122.

What is not clear?
@evalyn.Braun, it is unclear why in this line twice $codes write
echo chr($codes[array_rand($codes)]); - mariah commented on April 3rd 20 at 17:46
Same as:
$i = array_rand($codes); //Get a random array key
echo chr($codes[$i]); //Pass the value of this key to the function chr()
- retha.Braun commented on April 3rd 20 at 17:49
@evalyn.Braun, thank you very much - mariah commented on April 3rd 20 at 17:52
April 3rd 20 at 17:45
The question is not clear, you want to understand what makes array_merge? Connects 2 array where the first array consists of numbers from 65 to 90, and the second from 97 to 122, the result is an array [65,66,......,90,97,........,122]
@kolby, it is unclear why in this line twice $codes write
echo chr($codes[array_rand($codes)]); - mariah commented on April 3rd 20 at 17:48
@mariah, Read the basics of arrays in PHP array[key], in the end it turns out that we get a random value(number) from the array $codes - kolby commented on April 3rd 20 at 17:51

Find more questions by tags PHP