将foreach存储在数组中并通过电子邮件发送

时间:2016-01-25 20:44:05

标签: php arrays laravel foreach

我在尝试从foreach循环中获取多个结果时遇到问题,将它们存储在一个数组中,然后通过电子邮件发送最终的数组。到目前为止,我有类似的东西:

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!' );
        });
    }
}

这是使用Laravel。我知道这是一件非常简单的事情,但我总是心不在焉。欢迎任何建议!

谢谢:)

0 个答案:

没有答案