I am confused about why I can't print the content of $positions
using the code below.
$rows = query("SELECT * FROM protfolio WHERE id = ?", $_SESSION["id"]);
$positions = [];
foreach ($rows as $row)
{
$stock = lookup($row["symbol"]);
if ($stock !== false)
{
$positions[] = [
"name" => $stock["name"],
"price" => $stock["price"],
"shares" => $row["shares"],
"symbol" => $row["symbol"]
];
}
}
$_SESSION["positions"] = $positions;
print_r($positions]);
render("portfolio.php", ["positions" => $positions, "title" => "Portfolio"]);
What does $positions = []
mean? Does it declare a 2d array?