0

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?

1
  • print $result value and post it Commented Mar 13, 2017 at 7:48

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.. check my updated question
0

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];

1 Comment

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..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.