0

我收到以下错误:

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 />';
            }
        }
    }
?>

谁能帮我??

4

2 回答 2

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];
于 2012-06-21T11:43:55.543 回答
0

$a_user是一个刺痛,但需要是一个数组!你需要解决这个问题。

于 2012-06-21T11:41:03.380 回答