0
我是php的新手。我想我的問題是strpos
。我嘗試了一切,但沒有任何幫助。將電子郵件添加到XML文件
PHP文件:
function addMailToXML() {
$new = $_POST['new-mail'];
$mails = array();
$subject = "";
$body = "";
$data = loadConfig();
if(!check_email_address($_POST['new-mail'])){
echo 'Wrong address!!!';
} else {
if(strpos($data['mails'], $new) !== false) {
echo 'Already in database!!!';
} else {
$data['mails'][] = trim($new);
saveConfig($data['mails'], $data['subject'], $data['body']);
echo 'Successfully registered.';
}
}
}
XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<item><mails>[email protected],[email protected],[email protected]</mails><subject></subject><body></body></item>
謝謝,我只是用in_array修復它。再次感謝。 – 2012-01-17 17:43:34