How to generate an array of Multiple recipients using mandrill

我们两清 提交于 2019-12-08 19:17:31

An effective way would be to use array_map I have added in some code that also takes an array of names as well (I couldn't see where you were getting the names from in your code).

$toAddresses = array('example@example.com','test@test.com','hello@test.com','world@test.com');
$names = array('Exmaple', 'Test', 'Hello', 'World');

$mandrillTo = array_map( function ($address, $name) {
    return array(
        'email' => $address,
        'name' => $name
    );
},
$toAddresses,
$names
);

This passes the 0th element from each array into the function and returns an array of two values, then passes the 1st, 2nd etc and returns each result in a new array ($mandrillTo)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!