A
A
Alex_mos2020-12-28 09:22:56
PHP
Alex_mos, 2020-12-28 09:22:56

How to display data in PHPMailer?

Such a question has not previously worked with PHP.
Through ajax, data is sent from inputs (name and phone) and an object from localStorage.

There are no problems with the name and phone number in the php handler, but what comes from localStorage outputs an array, and as I understand it, the array is multidimensional.
How to output all arrays that array contains and send data via PHPMailer?

I tried to do something like this through foreach:

foreach ($data as $value){
$dex="
<span>$value[name]</span><br/>
<span>$value[price]</span><br/>
итд......
"
$body="
<span>имя</span><b>(имя из инпута)</b>
<span>имя</span><b>(телефон из инпута)</b>
<span>имя</span><b>$dex</b>
"
}


Then this body is added to be sent via PHPMailer, but only one object data gets into the $dex variable

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-12-28
@Alex_mos

Because you overwrite the variable every time. Use .= if I understand the task correctly. $body .= ....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question