如何在每个电子邮件地址中添加单引号或双引号

时间:2013-09-03 17:13:45

标签: php mysql regex

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

内爆之后

我的电子邮件应该是这样的

(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)

1 个答案:

答案 0 :(得分:2)

然后使用该字符串implode

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

以下是演示:http://codepad.viper-7.com/3suUci