0

i try to send the looped echo output via mail like below.

Do i have to transfer the output into an array first?

<?php
$jsonData = file_get_contents("https://test.com");
$data = json_decode($jsonData,true);
foreach ($data["results"] as $value) {

    if($value["fuel"]=="Elektro"){
    echo ($value[product_stock_total]);
    echo "*";

}}
?>

<?php
$to = "[email protected]";
$subject = "This is a test HTML email";

$message = "
<html>
<head>
<title>$total</title>
</head>
<body>
<p>Gesamt: $total</p>
<p>MINI: $totalmini</p>
</body>
</html>
";

mail($to,$subject,$message,$headers);
?>

Thanks in advance :)

2
  • 1
    Instead of echo put the values in a variable. Then include the variable in $message somewhere. If product_stock_total is an index that should be quoted as well. Commented Apr 16, 2021 at 20:30
  • More examples: !ddso php collect foreach output to variable Commented Apr 16, 2021 at 20:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.