Вывести содержимое массива в почту - phpmailer - PullRequest
1 голос
/ 06 апреля 2020

Итак, у меня есть

почта. php -> отправляет почту

index. php -> структура тела письма

Я хочу отправить значения массива из mail. php для индексации. php и итерации содержимого массива в html.

mail. php

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php'; 
require '../inc/database.php';

$query = "  query " ;

$result = mysqli_query($link,$query);
if(mysqli_num_rows($result))
{
    while($row = mysqli_fetch_assoc($result))
    {
        $arr[]=$row;
        print_r($arr);
    }
} 
// $arr returns Array ( [0] => Array ( [val1] => 1 [val2] => 2 ) [1] => Array ( [val1] => a [val2] => b) 

....
mail->MsgHTML(file_get_contents("index.php")); // Body of my mail 
...
?>

index. php

...
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 <tr>
   <td style="padding: 15px 0 0 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
      // Display my array contents here 
   </td>
  </tr>                                                            
</table>
...

я хочу, чтобы мой вывод выглядел следующим образом:

1: 2

a: b

Как этого достичь? Как я могу передать переменные массива из mail. php page в index. php page и l oop там значение массива?

...