My code is like this : http://pastebin.com/G74JY27f
<?php
$param = array('sex'=>'Mr.',
'family_name'=>'Mourinho',
'first_name'=>'Jose',
'booking_phone'=>'123456',
'booking_mobile'=>'123',
'booking_email'=>'mourinho@gmail.com',
'passenger_sex'=>array(
'Sgl'=>array('Mr.'),
'Dbl'=>array('Mr.','Mr.','Mr.','Mr.'),
),
'passenger_family_name'=>array(
'Sgl'=>array('Bale'),
'Dbl'=>array('Hazard','Ronaldo','Messi','Beckham'),
),
'passenger_first_name'=>array(
'Sgl'=>array('Gareth'),
'Dbl'=>array('Eden','Christiano','Lionel','David'),
)
);
echo '<pre>';print_r($param);echo '</pre>';
$xml = "<?xml version='1.0' encoding='utf-8' ?>
<Request>
<BookingRequest>
<Name>".$param['first_name']."</Name>
<Email>".$param['booking_email']."</Email>
<Phone>".$param['booking_phone']."</Phone>
<MPhone>".$param['booking_mobile']."</MPhone>
<Passenger Room='SGL'>
<PassSex>Mr</PassSex>
<PassLocalNm>Gareth</PassLocalNm>
<PassFirstNm> Gareth </PassFirstNm>
<PassLastNm> Bale</PassLastNm>
</Passenger>
</BookingRequest>
</Request>";
$json = json_encode($xml);
$response_array = json_decode($json,TRUE);
print_r($response_array);
die();
?>
The result of print_r($param)
, it is an array
The result of print_r($response_array)
, it is xml
Name tag, email tag, phone tag and mphone tag in xml, that according to the data from the array
But the problem is the passenger tag, it still static
Seems using foreach, but I am still confused
The result there will be five passenger tag
So I want output like this http://pastebin.com/t380Aits
How to order the output looks like the above link?