This is a simple question yet I'm unable to find an answer to this. I'm not looking for corrections to my code, simply education regarding this issue.
The array is defined before the first foreach begins so I can use it outside of the loop.
$arrayVar = array();
foreach ($variables as $key => $variable){
$arrayVar = array(
'name' => $squad['full_name'],
'position' => $squad['position']
);
}
This populates the array with data. However, when used in another loop, the array resets instead of appending to the end.
EDIT: John's answer resolves the issue. A simple inclusion of square brackets has saved me around 1000 lines.