D
D
Develm2015-11-24 08:30:22
PHP
Develm, 2015-11-24 08:30:22

How to extract $_POST array by elements?

There is a code:

if(isset($_POST['sendmessege'])){
  $body = "Пользователь заказал: <br>";
  $mail_subject = "Заказ";
  $to = "[email protected]";
  $mail_headers="content-type:text/html; charset=UTF-8";

  foreach($_POST as $key => $array){
    $body .= "{$array}<br>";
  }
  mail($to, $mail_subject, $body, $mail_headers); 
}

How can you do that?
$body .= "{'Some text - '$array['First element'],'Some text' - $array['Second element'],'Some text' - $array['Third element'] }"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Railchik, 2015-11-24
@Railchik

array_shift
But it's better not to do that!

E
Evgeny Svirsky, 2015-11-24
@e_svirsky

It's not a good approach to POST directly somewhere... I would sanitize first.
But if needed:
implode('<br>', $_POST);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question