XML : How to Storing a loop as a string in a variable?

My Code is like this :

  <?php          $HCode = 'IDJKT01';          $CheckIn = '2016-02-01';          $CheckOut = '2016-02-02';          $Sgl = 1;          $Dbl = 0;          $Trp = 0;          $RmGrade = 'DELUXE';            $xml = "<?xml version='1.0' encoding='utf-8' ?>                                <Request>                                    <BookingRequest>                                                           <HCode>".$HCode."</HCode>                                        <RmGrade>".$RmGrade."</RmGrade>                                        <CheckIn>".$CheckIn."</CheckIn>                                        <CheckOut>".$CheckOut."</CheckOut>                                         <Sgl>".$Sgl."</Sgl>                                         <Dbl>".$Dbl."</Dbl>                                         <Trp>".$Trp."</Trp>                                         <Passenger Room='SGL'>                                            <PassSex>M</PassSex>                                            <PassLocalNm>Becks</PassLocalNm>                                            <PassFirstNm> David </PassFirstNm>                                            <PassLastNm> Beckham</PassLastNm>                                        </Passenger>                                    </BookingRequest>                                </Request>";  ?>    

I want to add loop in string.

For example as above, If $sgl = 1, then the number of passenger tag is 1

Other examples such as $sgl = 3, then the number of passenger tag is 3

Other examples such as $double = 1, then the number of passenger tag is 2

Any help much appreciated

Cheers

No comments:

Post a Comment