D
D
Develm2015-11-25 13:04:34
PHP
Develm, 2015-11-25 13:04:34

And again $_POST How to split an array?

The code:

$body = "Пользователь заказал: <br>";
  $mail_subject = "Заказ";
  $to = "почта";
  $mail_headers="content-type:text/html; charset=UTF-8";
  foreach($_POST as $key => $array){
    $body .= "{$key}: {$array}<br />";
  }
  mail($to, $mail_subject, $body, $mail_headers);

How can you do this: write the 1st and 2nd values ​​in one line
,
the 3rd and 4th
, etc.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene, 2015-11-25
@Nc_Soft

You need to study the php.net/array documentation .
This, of course, is not as fun as scribbling questions of the same type on a toaster, but more efficient.

M
Maxim Timofeev, 2015-11-25
@webinar

If you need key-value pairs, you can put them in json.
If just values:

$arr = $_POST;
$stroka = implode(",", $arr);

Also pay attention to
www.php.su/functions/?vprintf
and
www.php.su/functions/?printf

M
Max, 2015-11-25
@matios

Have you heard of division with remainder?

$body .= "{$key}: {$array}";
if ($key % 2 == 0) {
    $body .= "<br />";
} else {
     $body .= " - ";
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question