我正在处理这个程序,这里我试图用','分隔字符串电子邮件,然后我存储在数组中,然后在foreach中附加'city'..
$email='aa,bb,cc,dd';
$a=explode(',',$email);
//echo $a[2];
$result="";
foreach($a as $v)
{
$result .= " city = '$v' ";
echo $result;
}
我得到的结果是
city = 'aa' city = 'aa' city = 'bb' city = 'aa' city = 'bb' city = 'cc' city = 'aa' city = 'bb' city = 'cc' city = 'dd'
但我希望它是,,
city = 'aa' city = 'bb' city = 'cc' city = 'dd'
我的代码错了吗?..请指导我..