Array
(
[id] =>
[name] => hjkjh
[email] => hjkhjk@gail.zfcc
[address] => fsdf
[gender] => female
[city] => MUMBAI
[hobbies] => Array
(
[0] => dance
[1] => reading
)
[myimage] =>
)
我想传递电子邮件正文中的值 如何通过VALUES 这个数组是$ data 我想要这个
name = value
email= value
有人可以帮忙吗
答案 0 :(得分:1)
您可以使用
$name = $your_array["name"];
$email = $your_array["email"];
$address = $your_array["address"];
$gender = $your_array["gender"];
$city = $your_array["city"];
$hobbies = '';
foreach($your_array["hobbies"] as $key=>$val){
$hobbies .= $val.' ';
}
最后,您可以在电子邮件代码中使用上述变量。
从上一条评论中更新,您可以按照
的方式进行操作 foreach($data as $key=>$value) {
$body .=$key."=";
if($key== 'hobbies'){
foreach($value as $k=>$v){
$body .= $v.' ';
}
$body .= "\n";
}else{
$body .=$value."\n";
}
}
$body .= "\n";
答案 1 :(得分:1)
检查一下:
$data=array(
"id" =>1,
"name" => "hjkjh",
"email" => "hjkhjk@gail.zfcc",
"address" => "fsdf",
"gender" => "female",
"city" => "MUMBAI",
"hobbies" => Array
(
0 => "dance",
1 => "reading"
),
"myimage" => ""
);
$body="";
$body.="Name :".$data['name']."<br/>";
$body.="Email :".$data['email']."<br/>";
$body.="Address :".$data['address']."<br/>";
$body.="Gender :".$data['gender']."<br/>";
$body.="City :".$data['city']."<br/>";
$body.="Hobbies :".$data['hobbies'][0].", ".$data['hobbies'][1]."<br/>";
echo $body;
其O / P如下: -
Name :hjkjh
Email :hjkhjk@gail.zfcc
Address :fsdf
Gender :female
City :MUMBAI
Hobbies :dance, reading
我希望这就是你所需要的!
答案 2 :(得分:0)
$string = implode( ", ",$array);
将起作用....访问链接http://www.dreamincode.net/forums/topic/233154-printing-out-a-php-array-in-an-email-body/了解详情........谢谢