0

如何在每封电子邮件中添加单引号或双引号添加示例

内爆后我的电子邮件应该是这样的

(red@yahoo.com, blue@yahoo.com, yellow@yahoo.com, white@yahoo.com)

将该数组字符串转换为:

('red@yahoo.com', 'blue@yahoo.com', 'yellow@yahoo.com', 'white@yahoo.com')

或者

("red@yahoo.com", "blue@yahoo.com", "yellow@yahoo.com", "white@yahoo.com")



    $num = count($email);
   for($i=0; $i < $num; $i++){
    $result = do_post_request("http://api.myapi.com/api/IsActiveAccount?email=".  $email[$i], null);
    $status = str_replace('{"result":', "", $result);
    $status = str_replace('}', "", $status);
    $value_email[] = $email[$i] ;
    $value_status[] = $status ;
}
  $val_email = implode(',',$value_email);
  $value_status = implode(',',$value_status);

  define ("VERIFY_EMAIL_UPDATE_SENT", " UPDATE `accounts` SET sent = 1 WHERE email IN (".$val_email.") AND active <> 1");
  $db->query(VERIFY_EMAIL_UPDATE_SENT);
  echo 'Done'; 

  Error because ---->email IN (red@yahoo.com, blue@yahoo.com, yellow@yahoo.com, white@yahoo.com)
4

1 回答 1

2

然后只需implode使用该字符串:

$result = '("' . implode('", "', $emails) . '")';

这是一个演示:http ://codepad.viper-7.com/3suUci

于 2013-09-03T17:14:44.933 回答