I'm having issues trying to take multiple results from a foreach loop, store them in an array and then email the finalised array. I've got something like this so far:
foreach ($term as $term) {
$dbdata = $term['term'];
$user = $term['email'];
$html = file_get_html('www.test.com/test');
$partial = $html->find('ul.test');
$host = 'www.test.com';
$a = new \SimpleXMLElement($partial); //Grab just the relative url
$href = $a['href'];
$html2 = file_get_contents($host.$href);
if (preg_match("/$dbdata/i", $html2)) {
$data = array(
'term' => $dbdata,
'link' => $link,
'user' => $user,
'from' => 'myproject@test.com'
);
Mail::queue( 'emails.sup', $data, function($message) use ($data) {
$message->to( $data['user'] )
->from( $data['from'])
->subject( 'We got the following things for you!' );
});
}
}
This is using Laravel. I know this is a very simple thing but I'm having a total mind blank with it. Any advice welcome!
Thanks :)