how to pass array through hidden field

后端 未结 7 1870
醉梦人生
醉梦人生 2020-12-05 00:59

here my code

$order[$j][0]=\"Euclidean Geomethiyil Kodpagugal\";
$order[$j][1]=$q16;
$j++;

hidden field-



        
相关标签:
7条回答
  • 2020-12-05 01:50

    Try json_encode:

    <input type="hidden" name="hdnTotal" value="<?php echo htmlspecialchars(json_encode($gtot)); ?>">
    <input type="hidden" name="hdnOrder" value="<?php echo htmlspecialchars(json_encode($order)); ?>">
    <input type="submit" value="Place Order">
    

    and for get it back, json_decode:

    print(json_decode($_POST['hdnOrder']));
    

    The bonus of this solution is that you will able to manipulate your array at client side easily with JavaScript.

    But why do you want to do that ?

    If it is not for manipulate your data at client side, you create an an unnecessary round trip of your data, that you can easily keep at server side with PHP sessions.

    0 讨论(0)
提交回复
热议问题