If I declare a variable inside a foreach loop, such as:
foreach($myArray as $myData) { $myVariable = \'x\'; }
Does PHP destroy it, and
According to the debugger in my IDE (NuSphere PHPed) in your first example:
foreach($myArray as $myData) { $myVariable = 'x'; }
$myVariable is only created once.
$myVariable