Let's set out some working variables:
$m = "name";
$n = strlen($m);
$r = rand(1,$n);
$c = substr($m, $r -1, 1);
Everything to the right of the equals sign is an expression. All four of them. Each building on the one before it, and resolving in the final expression.
$m is self evident. It is a string expression.
$n is the string length. We know that it is 1 more than we need it, but I like to resolve things rather than mutate the output of a pure function.
$r is random number between
$n, inclusive. I start with
1 because I don't want the subtraction later to give a negative 1. Again, I want a pure result, not one I've mutated.
With 1 and $n both being offset by 1, we're just shifting the whole range over by one. This is what takes place in the final expression,
$r - 1 expression..
This can be written into a single echo statement. Consider,
print substr($m, $r - 1, 1);
print substr($m, rand(1, $n) - 1, 1);
and now substituting for
print substr($m, rand(1, strlen($m)) - 1, 1);
and if we choose to go the distance, substitute for $m:
print substr("name", rand(1, strlen("name")) - 1, 1);
Now we have no variables, only the expressions they represented.
This example is not meant as a solution for you to pass. If any of the concepts are still fuzzy, go back and play around in the lessons for each function in this exercise. Be comfortable with them because they will be on call a lot.