This code displays the contents of an array in the format:

1 2 3 4
1 2 3 4
etc...

$data = $_POST['data'];
foreach ($data as $tempone) {
  foreach ($tempone as $key=>$temptwo) {
   echo "$temptwo", "\n";
  }
  echo "<br>";
 }

How can I get those results and use them in an email?

$message .= "the forloop results here"

There's a few similar questions about but none using a Multidimensional arrays.

This actually sorted it, not sure if it's right, but it works. Still open to suggestions if there's a better way to do it but I'll mark as solved (:

                foreach ($data as $tempone) {
  foreach ($tempone as $key=>$temptwo) {
   $message .= ''.$temptwo.''; 
  }
      $message .= '<br>';
 }

If you're using PHP 5.5+ then you could use array_column with implode(), for example:

<?php

// example contents
$_POST['data'][] = ['a' => 1];
$_POST['data'][] = ['a' => 2];
$_POST['data'][] = ['a' => 3];
//

$data = $_POST['data'];
$data = implode(' ', array_column($data, 'a'));

print $data;

That will print 1 2 3. Docs: http://php.net/array-column

commented: Nice +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.