The undefined variable is $new_string.
I wrote this little script because I needed it, (don't ask why).
$string = "abcdefghijklmnopqrstuvwxyz"; // just used as an example
// $string becomes "badcfehgjilknmporqtsvuxwzy"
$now_in_pairs = str_split($string, 2);
$reverse = array_map('strrev', $now_in_pairs);
foreach($reverse as $r) {
$new_string .= $r;
}
echo $new_string;
I know I could simply say, $new_string = NULL at the start to avoid the Undefined variable but that doesn't help me to understand why it isn't defined.
In very layman's terms, $r equals the value of each pairs in the array?
How can $new_string be undefined when it equals $r?