php - Simple array foreach -
i'm sure simple ... can't seem figure out. need send email each of email addresses mentioning points. both emails have 36 points.
$emails = $usertools->weeklymail();
print_r:
array ( [0] => array ( [0] => email1@gmail.com [1] => [2] => 36 ) [1] => array ( [0] => email2@gmail.com [1] => [2] => 25 ) )
loop:
foreach($emails $email) { $email = $email[0]; $subject = "you have ".$email[2]." points!!! !!!"; // message $message = "hello\r\nyou have ".$email[2]." points ."; $helperclass->sendemail($email, $subject, $message); }
your problem overwrite reference variable $email
means $email[2]
undefined.
change to:
foreach($emails $email) { // $email = $email[0]; can't use $email[2] if $email overwritten $subject = "you have ".$email[2]." points!!! !!!"; // message $message = "hello\r\nyou have ".$email[2]." points ."; $helperclass->sendemail($email[0], $subject, $message); }
Comments
Post a Comment