I use a HTML form with several fields. But i need to have the value from the select fields ( dropdown ) translated into a php aray. My form contains below fields:
City - Text
IN - Text/Date
OUT - Text/Date
Rooms - Select ( 1->5 )
Adults - Select ( 1->5 )
Childs - Select ( 0->5 )
The php array that i need to receive is
Example If Rooms is - 1 and Adults - 2 the response must be:
$rooms[] = array(array("paxType" => "Adult"), array("paxType" => "Adult"));
Example If Rooms is - 2 and Adults - 3 the response must be:
$rooms[] = array(array("paxType" => "Adult"), array("paxType" => "Adult"));
$rooms[] = array(array("paxType" => "Adult"));
I am using the below code
$Adults = intval($_POST["Adults"]);
$rooms = array();
for ($x = 0; $x < $Adults; $x++) {
array_push($rooms,array("paxType" => "Adult"));
}
but i am receive onbly the response with 1 room and 1 adult.