我收到了以下错误:
verzend mail naar t met attachment: e
verzend mail naar w met attachment: w
verzend mail naar r met attachment: a
verzend mail naar w met attachment: w
verzend mail naar r met attachment: a
verzend mail naar w met attachment: w
Notice: Uninitialized string offset: 0 in /variables.php on line 248
Notice: Uninitialized string offset: 1 in /variables.php on line 248
verzend mail naar met attachment:
这是我的代码:
<?php
$emailString = 'test@user.nl;www.test.nl^email1@live.nl;www.test2.nl^email3@live.nl;www.test3.nl^';
$user = explode("^", $emailString); // urls
foreach($user as $a_user) {
$user2 = explode(";", $a_user); // emails
$a_mailing = array();
foreach ($user2 as $a_user) {
$a_mailing[$a_user[0]][] = $a_user[1];
}
foreach($a_mailing as $key => $a_values) {
foreach($a_values as $value) {
echo 'verzend mail naar ' . $key . ' met attachment: ' . $value . '<br />';
}
}
}
?>
任何人都可以帮助我吗?
答案 0 :(得分:1)
问题是第一个循环中的$ a_user是一个字符串。例如..在第一次迭代中,$ a_user变量包含:“test@user.nl; www.test.nl”;
从我所看到的情况来看,我相信您只是尝试将电子邮件地址用作密钥,将url用作值,这样您就不需要使用第二个循环了。你可以替换:
foreach ($user2 as $a_user) {
$a_mailing[$a_user[0]][] = $a_user[1];
}
使用:
$a_mailing[$user2[0]][] = $user2[1];
答案 1 :(得分:0)
$a_user
是一个刺痛,但需要是一个阵列!你需要解决这个问题。