我从Mysql数据库中得到这个特定的字符串:
$string = "john('john@yahoo.com'), frank('frank@gmail.com'),simon('simon@to.com')";
我需要在下面的代码中插入字符串:
$sendSmtpEmail = new \SendinBlue\Client\Model\SendSmtpEmail([
'subject' => 'Report',
'sender' => ['name' => 'sender', 'email' => 'sender@domain.com'],
'to' => [
['name' => 'john', 'email' => 'john@domain.com'],
['name' => 'frank', 'email' => 'frank@domain.com'],
['name' => 'frank', 'email' => 'simon@domain.com']
],
'htmlContent' => $output
]);
显然,我需要$sendSmtpEmail
中包含关联行的2d数组,但如何创建它呢?
2条答案
按热度按时间a0zr77ik1#
我回答的有点晚,但是写信是为了帮助来这里寻找的人。希望这能帮助到一些人。
完整的脚本将在下面进行复制
mznpcxlj2#
使用
preg_match_all()
直接匹配一个或多个格式化子字符串序列。使用两个捕获组,然后将这些数据点Map到关联行。代码:(Demo)