In PHP, I have an array. I would like to send all values in the array to the next page (result.php). When I receive the values in $_POST, can I get them in the array as they were? (or I can only get the values of the array separately or concatenated, and re-generate the array afterwards?)
I tried the following code, but it only concatenates the values in the array, so it is not satisfactory.
Please let me know what would be the best practice either way. Of course, I prefer to keep the original array intact!
Thank you!
<form class="form_container validationForm" action="result.php" method="post">
<input type="hidden" name="targetobject[]" value="
<?php $postvalue = array("Volvo", "BMW", "Toyota"););
foreach($postvalue as $value){echo $value;}
?>
">
<input type="text" class="form-control validationInput" name="search" placeholder="Type a search keyword"><br><button class="btn btn-primary" type="submit">Search</button></div></form>
//The following is result.php
<?php $targetobject = $_POST['targetobject'];
echo var_dump($targetobject);
?>
array(3) { [0]=> string(5) "Volvo" [1]=> string(3) "BMW" [2]=> string(6) "Toyota" }
inputs, each with the nametargetobject[]each with one of the values?