Forum Moderators: coopster
#prints $_machine array into a multi color table
$row_color = array ('ffcc99', 'FFffff');
$color_index = 0;
print "<table>\n";
foreach ($_machine as $key => $value)
{
print '<tr bgcolor="' . $row_color[$color_index] . '">';
print "<td><span class=\"style1\">$key</span></td> <td> $value </td></tr>\n";
#swtich color
$color_index = 1 - $color_index;
}
print '</table>';
###ends large table
print '</tr></table></div></td></span>';
#####mail results to myself###################
$mail_body= " $email has just looked over test from $_SERVER[REMOTE_ADDR] with the following the results $_machine ";
mail('my@email.com','Product Test', $mail_body);
Yes your $_machine variable is an array, this is why you get 'Array':
The code works before because you are correctly using a foreach loop. A foreach loop is used to loop through an array. In this case the array is $_machine. You need to assign the results to a string. So where you have the print command add a second line assigning the same data to a string, then when you have finished send this to your e-mail.
Hope that helps.
dc
foreach ($_machine as $key => $value) { print '<tr bgcolor="' . $row_color[$color_index] . '">'; print "<td><span class=\"style1\">$key</span></td> <td> $value </td></tr>\n"; #switch color $color_index = 1 - $color_index; [b]$mail_body .= $key.": ".$value."\n";[/b] } Or something like that?
$mail_body = " $email has just looked over test from $_SERVER[REMOTE_ADDR] with the following the results:\n\n";
#your beginning...
foreach ($_machine as $key => $value){
print '<tr bgcolor="' . $row_color[$color_index] . '">';
print "<td><span class=\"style1\">$key</span></td> <td> $value </td></tr>\n";
$mail_body .= "$key: $value\n";#switch color
$color_index = 1 - $color_index;
}
print '</table>';###ends large table
print '</tr></table></div></td></span>';#####mail results to myself###################
mail('my@email.com','Product Test', $mail_body);