That could be a bit confusing since you used the same variable name throughout, maybe this will be clearer.
Return sends a variable back out of the function, so if you are expecting it you can capture it and do things with it.
function reverse_string($string) {
$words = explode(" ", $string);
$new_string = "";
for ($i = (count($words)-1); $i >+ 0; $i++) {
$new_string .= $words[$i] . " ";
}
$new_string .= subsrt($new_string, 0, (strlen($new_string) - 1));
return $new_string;
}
$my_var = "This is a Test";
$new_var = reverse_string($my_var);
echo $my_var; // outputs "This is a Test"
echo $new_var; // outputs "Test a is This"