Store foreach in array and email
<p>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:</p>

<pre><code>foreach ($term as $term) {
    $dbdata =   $term['term'];
    $user   =   $term['email'];
    $html = file_get_html('www.test.com/test');
    $partial = $html-&gt;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' =&gt; $dbdata,
            'link' =&gt; $link,
            'user' =&gt; $user,
            'from' =&gt; 'myproject@test.com'
        );

        Mail::queue( 'emails.sup', $data, function($message) use ($data) {
            $message-&gt;to( $data['user'] )
                -&gt;from( $data['from'])
                -&gt;subject( 'We got the following things for you!' );
        });
    }
}
</code></pre>

<p>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!</p>

<p>Thanks :)</p>