如何在php中获取循环外的foreach循环变量值?

I have following foreach loop:

$childDetails =array();
foreach( $result as $results ) {
    $applicationID = $results->booking_ID;
    $formType = $results->formType;
    $Student_name = $results->ChilldName;
    $payment = $results->Payment;
}

Now I want to get these variable values to be printed the out side of the loop

Application ID : here I have to echo $applicationID

Form type : here I have to echo $formType

Student Name : here I have to echo $Student_name

Payment : here I have to echo $payment

UPDATE:

I want to this because I have to echo the every variable and assign it to another variable.

eg : $mail_body_guest_full .= 'Form Type is' . $results->formType; how is that possible to use the above method to do this

If I echo $childDetailsoutside of the loop, it will print all of the variable values.. I want to print them one by one in different places of HTML..

how can do this?

Don't understand question , please explain waht you want to do ....

As i can see you have loop , and now you can print out every element with "echo" inside the loop.

Or

If you try echo outside loop , you will get last elements from $result.

Why do you want to print it outside foreach loop

Do it as

<?php 
   $i=0;
    foreach( $result as $results ) {
    ?>
    Application ID :<?php echo $results->booking_ID; ?>
    Form type :<?php echo $results->formType;?>
    Student Name : <?php echo $results->ChilldName;?>
    Payment :<?php echo $results->Payment;
    $mail_body_guest_full[i].= 'Form Type is' . $results->formType;
    $i++;
    }?>

then outside the loop

you can print it as

echo $mail_body_guest_full[0];