mercredi 25 avril 2018

PHP/Laravel 5.4 "Invalid argument supplied for foreach()"

I have a basic array of emails that I am attempting to foreach over in order to assign the values to another variable to send via Laravel mail. Here is a dump and die of the array, $emails, prior to the foreach:

array:4 [
  0 => "test@example.com"
  1 => "testTwo@example.com"
  2 => "testThree@example.com"
  3 => "testFour@example.com"
]

And the foreach is:

foreach ($emails as $email) {
    $this->bcc = $email;
}

I'm not sure why I'd be getting this error, as this is clearly an array. Ultimately I am attempting to send to multiple emails, but just assigning this array to the mailable's bcc:

$this->bcc = $emails;

results in the error Illegal string offset 'address', though a dump and die of $this shows the array is in the bcc property:

enter image description here

Anyone see the core issue here, beyond my lack of knowledge regarding sending multiple emails with Laravel? Cheers!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2FekttJ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire