I've tried to pass the array from quote.php to a template result_symbol.php using this code.


    // configuration

   // if user reached page via GET (as by clicking a link or via redirect)
    // else render form
    render("quote_form.php", ["title" => "Quote"]);
// else if user reached page via POST (as by submitting a form via POST)
else if ($_SERVER["REQUEST_METHOD"] == "POST")
    // TODO
    apologize("Bad symbol.");
$quote = [];
$stock = lookup($_POST["symbol"]);
$quote[] = [
"symbol" => $stock["symbol"],
"name" => $stock["name"],
"price" => $stock["price"]
render("result_symbol.php", ["quote" => $quote, "title" => "Quote"]);



But that gives me an error when using this template code:

    <form action="../public/quote.php" method="post">
    <div class="form-group">
        print("Symbol : ".$quote["symbol"]."\n");
    print "\n";
    print("Name   : ".$quote["name"])."\n";
    print "\n";
    print("Price  : ");
    print number_format($quote["price"], 4);

or Quote other or Log in

But i got an error:undefined symbol What am i doing wrong? However, if i call lookup from inside the template, it works.

1 Answer 1


I've used the print_r function, it showed me the array was doubly indexed (don't know why, but...), so when i referenced with 2 indexes it worked.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .