Currently working through pset7 (Finance) and can't seem to wrap my head around how this piece of code works:
$positions = [];
//iterate through rows
foreach ($rows as $row)
{
$stock = lookup($row["symbol"]);
if ($stock !== false)
{
$positions[] = [
"name" => $stock["name"],
"price" => $stock["price"],
"shares" => $row["shares"],
"symbol" => $row["symbol"]
];
}
}
Through every iteration through rows, wouldn't $positions["shares"] and $positions["symbol"] get over written by the new values from $row["shares"] and $row["symbol"]? How is $positions able to store all the rows of $rows?