How to pass an array into a PHP SoapClient call
'stay' has to be defined just once. This should be the right answer:
$xml = array('reservation' => array(
'stays' => array(
'stay' => array(
array(
'start_date' => '2011-01-01',
'end_date' => 2011-01-15
),
array(
'start_date' => '2011-01-01',
'end_date' => 2011-01-15
)
)
)
));
Assuming that when you instantiated $soapClient
, you did so in WSDL mode, the following should work:
$stay1 = new stdClass();
$stay1->start_date = "2011-01-01";
$stay1->end_date = "2011-01-15";
$stay2 = new stdClass();
$stay2->start_date = "2011-01-01";
$stay2->end_date = "2011-01-15";
$stays = array();
$stays[0] = $stay1;
$stays[1] = $stay2;
$soapClient->saveReservation(
array("reservation" => array("stays" => $stays))
);